]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
super-intel.c: fix memleak in find_disk_attached_hba()
authorWu Guanghao <wuguanghao3@huawei.com>
Fri, 3 Mar 2023 16:21:34 +0000 (00:21 +0800)
committerJes Sorensen <jes@trained-monkey.org>
Wed, 8 Mar 2023 18:54:30 +0000 (13:54 -0500)
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 <wuguanghao3@huawei.com>
Reviewed-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Acked-by: Coly Li <colyli@suse.de>
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
super-intel.c

index 4a3da847a7612c7644df8b73fd87408f98d0c5e2..e155a8ae99cb420724900d146a8e430786dfb223 100644 (file)
@@ -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,