From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
To: Wu Guanghao <wuguanghao3@huawei.com>
Cc: <jes@trained-monkey.org>, <linux-raid@vger.kernel.org>,
Paul Menzel <pmenzel@molgen.mpg.de>, <linfeilong@huawei.com>,
<lixiaokeng@huawei.com>
Subject: Re: [PATCH 1/5 v2] parse_layout_faulty: fix memleak
Date: Fri, 10 Jun 2022 11:13:10 +0200 [thread overview]
Message-ID: <20220610111310.0000315d@linux.intel.com> (raw)
In-Reply-To: <00ae6b42-b561-6542-0421-4ab8542d5d75@huawei.com>
On Thu, 9 Jun 2022 11:06:13 +0800
Wu Guanghao <wuguanghao3@huawei.com> wrote:
> char *m is allocated by xstrdup but not free() before return, will cause
> a memory leak.
>
> Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
> ---
> util.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/util.c b/util.c
> index cc94f96e..46b04afb 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
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
next prev parent reply other threads:[~2022-06-10 9:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 3:05 [PATCH 0/5 v2] mdadm: fix memory leak and double free Wu Guanghao
2022-06-09 3:06 ` [PATCH 1/5 v2] parse_layout_faulty: fix memleak Wu Guanghao
2022-06-10 9:13 ` Mariusz Tkaczyk [this message]
2022-07-28 21:15 ` Jes Sorensen
2022-08-01 8:07 ` Wu Guanghao
2022-06-09 3:06 ` [PATCH 2/5 v2] Detail: " Wu Guanghao
2022-06-20 17:04 ` Coly Li
2022-06-09 3:07 ` [PATCH 3/5 v2] load_imsm_mpb: fix double free Wu Guanghao
2022-06-10 9:14 ` Mariusz Tkaczyk
2022-06-09 3:08 ` [PATCH 4/5 v2] find_disk_attached_hba: fix memleak Wu Guanghao
2022-06-10 9:16 ` Mariusz Tkaczyk
2022-06-09 3:09 ` [PATCH 5/5 v2] get_vd_num_of_subarray: " Wu Guanghao
-- strict thread matches above, loose matches on Subject: below --
2022-08-02 2:14 [PATCH 0/5 v2 resend] mdadm: fix memory leak and double free Wu Guanghao
2022-08-02 2:15 ` [PATCH 1/5 v2] parse_layout_faulty: fix memleak Wu Guanghao
2022-09-03 8:26 ` Coly Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220610111310.0000315d@linux.intel.com \
--to=mariusz.tkaczyk@linux.intel.com \
--cc=jes@trained-monkey.org \
--cc=linfeilong@huawei.com \
--cc=linux-raid@vger.kernel.org \
--cc=lixiaokeng@huawei.com \
--cc=pmenzel@molgen.mpg.de \
--cc=wuguanghao3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.