]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
util.c: fix memleak in parse_layout_faulty()
authorWu Guanghao <wuguanghao3@huawei.com>
Fri, 3 Mar 2023 16:21:31 +0000 (00:21 +0800)
committerJes Sorensen <jes@trained-monkey.org>
Wed, 8 Mar 2023 18:54:30 +0000 (13:54 -0500)
char *m is allocated by xstrdup but not free() before return, will cause
a memory leak

Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Acked-by: Coly Li <colyli@suse.de>
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
util.c

diff --git a/util.c b/util.c
index b0b7aec4e0d4d419887b4500549eaa634034bc78..9f1e1f7c1279f87ee01edd1da2656d5c45cc5244 100644 (file)
--- a/util.c
+++ b/util.c
@@ -432,6 +432,8 @@ int parse_layout_faulty(char *layout)
        m = xstrdup(layout);
        m[ln] = 0;
        mode = map_name(faultylayout, m);
+       free(m);
+
        if (mode == UnSet)
                return -1;