From: Xiao Ni Date: Fri, 26 Jul 2024 07:14:16 +0000 (+0800) Subject: mdadm/super1: fix coverity issue RESOURCE_LEAK X-Git-Tag: mdadm-4.4~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae2308ddf38b8f24a2b5e8e14e31153dfe608239;p=thirdparty%2Fmdadm.git mdadm/super1: fix coverity issue RESOURCE_LEAK Fix resource leak problems in super1.c Signed-off-by: Xiao Ni Signed-off-by: Mariusz Tkaczyk --- diff --git a/super1.c b/super1.c index 243eeb1a..9c9c7dd1 100644 --- 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; }