]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm/super1: fix coverity issue CHECKED_RETURN
authorXiao Ni <xni@redhat.com>
Fri, 26 Jul 2024 07:14:13 +0000 (15:14 +0800)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Mon, 5 Aug 2024 09:13:49 +0000 (11:13 +0200)
It needs to check return value when functions return value.

Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
super1.c

index 81d29a652f3645d7596c7026716b2e596aafd701..4e4c7bfd15ae64521b8db74918c29e1d79a5fb19 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -260,7 +260,10 @@ static int aread(struct align_fd *afd, void *buf, int len)
        n = read(afd->fd, b, iosize);
        if (n <= 0)
                return n;
-       lseek(afd->fd, len - n, 1);
+       if (lseek(afd->fd, len - n, 1) < 0) {
+               pr_err("lseek fails\n");
+               return -1;
+       }
        if (n > len)
                n = len;
        memcpy(buf, b, n);
@@ -294,14 +297,20 @@ static int awrite(struct align_fd *afd, void *buf, int len)
                n = read(afd->fd, b, iosize);
                if (n <= 0)
                        return n;
-               lseek(afd->fd, -n, 1);
+               if (lseek(afd->fd, -n, 1) < 0) {
+                       pr_err("lseek fails\n");
+                       return -1;
+               }
        }
 
        memcpy(b, buf, len);
        n = write(afd->fd, b, iosize);
        if (n <= 0)
                return n;
-       lseek(afd->fd, len - n, 1);
+       if (lseek(afd->fd, len - n, 1) < 0) {
+               pr_err("lseek fails\n");
+               return -1;
+       }
        return len;
 }
 
@@ -2667,7 +2676,10 @@ static int locate_bitmap1(struct supertype *st, int fd, int node_num)
        }
        if (mustfree)
                free(sb);
-       lseek64(fd, offset<<9, 0);
+       if (lseek64(fd, offset<<9, 0) < 0) {
+               pr_err("lseek fails\n");
+               ret = -1;
+       }
        return ret;
 }