nvramtool: check for successful seek

Otherwise the following write might end up anywhere.

Change-Id: Ie42d984824e9308bd58b8bb905b6ea823543adf0
Found-by: Coverity Scan
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Reviewed-on: http://review.coreboot.org/6560
Tested-by: build bot (Jenkins)
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
diff --git a/util/nvramtool/cli/nvramtool.c b/util/nvramtool/cli/nvramtool.c
index d5acc58..bdfaaff 100644
--- a/util/nvramtool/cli/nvramtool.c
+++ b/util/nvramtool/cli/nvramtool.c
@@ -163,8 +163,8 @@
 		}
 
 		if (fd_stat.st_size < CMOS_SIZE) {
-			lseek(fd, CMOS_SIZE - 1, SEEK_SET);
-			if (write(fd, "\0", 1) != 1) {
+			if ((lseek(fd, CMOS_SIZE - 1, SEEK_SET) == -1) ||
+			    (write(fd, "\0", 1) != 1)) {
 				fprintf(stderr, "Unable to extended '%s' to its full size.\n",
 						nvramtool_op_modifiers[NVRAMTOOL_MOD_USE_CMOS_FILE].param);
 				exit(1);