From: Wu Guanghao Date: Fri, 3 Mar 2023 16:21:34 +0000 (+0800) Subject: super-intel.c: fix memleak in find_disk_attached_hba() X-Git-Tag: mdadm-4.3~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d2434d18b6bc71bd16678b1a6d1cc3a92f1d415;p=thirdparty%2Fmdadm.git super-intel.c: fix memleak in find_disk_attached_hba() If disk_path = diskfd_to_devpath(), we need free(disk_path) before return, otherwise there will be a memory leak Signed-off-by: Wu Guanghao Reviewed-by: Mariusz Tkaczyk Acked-by: Coly Li Signed-off-by: Jes Sorensen --- diff --git a/super-intel.c b/super-intel.c index 4a3da847..e155a8ae 100644 --- a/super-intel.c +++ b/super-intel.c @@ -713,12 +713,12 @@ static struct sys_dev* find_disk_attached_hba(int fd, const char *devname) for (elem = list; elem; elem = elem->next) if (path_attached_to_hba(disk_path, elem->path)) - return elem; + break; if (disk_path != devname) free(disk_path); - return NULL; + return elem; } static int find_intel_hba_capability(int fd, struct intel_super *super,