]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm: Fix memory leak issue in load_ddf_local()
authorWu Guanghao <wuguanghao3@huawei.com>
Tue, 14 Oct 2025 03:49:11 +0000 (11:49 +0800)
committerXiaoNi87 <xni@redhat.com>
Thu, 16 Oct 2025 14:02:02 +0000 (22:02 +0800)
dl->devname might be allocated space through xstrdup(). Before an
abnormal exit, it needs to be checked and released.

Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
super-ddf.c

index 7b38f91251342726912fcf54472d55832167800b..657c53abe72949dd45ad0add78a76e3b1a6edc84 100644 (file)
@@ -1208,6 +1208,8 @@ static int load_ddf_local(int fd, struct ddf_super *super,
        dl->devname = devname ? xstrdup(devname) : NULL;
 
        if (fstat(fd, &stb) != 0) {
+               if (dl->devname)
+                       free(dl->devname);
                free(dl);
                return 1;
        }