Re: [PATCH 1/5 v2] parse_layout_faulty: fix memleak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> 2022年8月2日 10:15,Wu Guanghao <wuguanghao3@xxxxxxxxxx> 写道:
> 
> char *m is allocated by xstrdup but not free() before return, will cause
> a memory leak
> 
> Signed-off-by: Wu Guanghao <wuguanghao3@xxxxxxxxxx>
> Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@xxxxxxxxxxxxxxx>

Acked-by: Coly Li <colyli@xxxxxxx>

Thanks.

Coly Li

> ---
> util.c | 3 +++
> 1 file changed, 3 insertions(+)
> 
> diff --git a/util.c b/util.c
> index 38f0420e..2e0f1de7 100644
> --- a/util.c
> +++ b/util.c
> @@ -427,8 +427,11 @@ int parse_layout_faulty(char *layout)
>        int ln = strcspn(layout, "0123456789");
>        char *m = xstrdup(layout);
>        int mode;
> +
>        m[ln] = 0;
>        mode = map_name(faultylayout, m);
> +       free(m);
> +
>        if (mode == UnSet)
>                return -1;
> 
> --
> 2.27.0





[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux