powerpc/boot: Fix missing check of lseek() return value
authorBo YU <tsu.yubo@gmail.com>
Tue, 30 Oct 2018 13:21:55 +0000 (09:21 -0400)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 2 May 2019 16:54:57 +0000 (02:54 +1000)
This is detected by Coverity scan: CID: 1440481

Signed-off-by: Bo YU <tsu.yubo@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/boot/addnote.c

index 9d9f6f334d3cc022f8c1ee39c30fe802863b38b0..3da3e2b1b51bcb8ac55a52b11ace265a775a22ce 100644 (file)
@@ -223,7 +223,11 @@ main(int ac, char **av)
        PUT_16(E_PHNUM, np + 2);
 
        /* write back */
-       lseek(fd, (long) 0, SEEK_SET);
+       i = lseek(fd, (long) 0, SEEK_SET);
+       if (i < 0) {
+               perror("lseek");
+               exit(1);
+       }
        i = write(fd, buf, n);
        if (i < 0) {
                perror("write");