]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm/super1: fix coverity issue RESOURCE_LEAK
authorXiao Ni <xni@redhat.com>
Fri, 26 Jul 2024 07:14:16 +0000 (15:14 +0800)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Mon, 5 Aug 2024 09:14:30 +0000 (11:14 +0200)
Fix resource leak problems in super1.c

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

index 243eeb1a017437d7465e550729f40fb2c38c1aa5..9c9c7dd14c150d8c04e9ac92ba9c3c49ca5a4d65 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -923,10 +923,12 @@ static int examine_badblocks_super1(struct supertype *st, int fd, char *devname)
        offset <<= 9;
        if (lseek64(fd, offset, 0) < 0) {
                pr_err("Cannot seek to bad-blocks list\n");
+               free(bbl);
                return 1;
        }
        if (read(fd, bbl, size) != size) {
                pr_err("Cannot read bad-blocks list\n");
+               free(bbl);
                return 1;
        }
        /* 64bits per entry. 10 bits is block-count, 54 bits is block
@@ -947,6 +949,7 @@ static int examine_badblocks_super1(struct supertype *st, int fd, char *devname)
 
                printf("%20llu for %d sectors\n", sector, count);
        }
+       free(bbl);
        return 0;
 }