diff mbox series

[2/5,v2] Detail: fix memleak

Message ID 32551992-ff6d-3d42-51dd-54e0a69e0cfd@huawei.com (mailing list archive)
State Superseded, archived
Headers show
Series mdadm: fix memory leak and double free | expand

Commit Message

Wu Guanghao Aug. 2, 2022, 2:15 a.m. UTC
char *sysdev = xstrdup() but not free() in for loop, will cause memory
leak

Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
 Detail.c | 1 +
 1 file changed, 1 insertion(+)

--
2.27.0

Comments

Coly Li Sept. 3, 2022, 8:26 a.m. UTC | #1
> 2022年8月2日 10:15,Wu Guanghao <wuguanghao3@huawei.com> 写道:
> 
> char *sysdev = xstrdup() but not free() in for loop, will cause 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>

Thanks.

Coly Li

> ---
> Detail.c | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/Detail.c b/Detail.c
> index ce7a8445..4ef26460 100644
> --- a/Detail.c
> +++ b/Detail.c
> @@ -303,6 +303,7 @@ int Detail(char *dev, struct context *c)
>                                if (path)
>                                        printf("MD_DEVICE_%s_DEV=%s\n",
>                                               sysdev, path);
> +                               free(sysdev);
>                        }
>                }
>                goto out;
> --
> 2.27.0
diff mbox series

Patch

diff --git a/Detail.c b/Detail.c
index ce7a8445..4ef26460 100644
--- a/Detail.c
+++ b/Detail.c
@@ -303,6 +303,7 @@  int Detail(char *dev, struct context *c)
                                if (path)
                                        printf("MD_DEVICE_%s_DEV=%s\n",
                                               sysdev, path);
+                               free(sysdev);
                        }
                }
                goto out;