From: Jiri Slaby <jslaby@suse.cz>
To: Gen Zhang <blackgod016574@gmail.com>,
mturquette@baylibre.com, sboyd@kernel.org
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: fix a missing-free bug in clk_cpy_name()
Date: Wed, 5 Jun 2019 08:38:00 +0200 [thread overview]
Message-ID: <eb8e2d33-e8f7-93a5-c8bc-98731c0d63b6@suse.cz> (raw)
In-Reply-To: <20190531011424.GA4374@zhanggen-UX430UQ>
On 31. 05. 19, 3:14, Gen Zhang wrote:
> In clk_cpy_name(), '*dst_p'('parent->name'and 'parent->fw_name') and
> 'dst' are allcoted by kstrdup_const(). According to doc: "Strings
> allocated by kstrdup_const should be freed by kfree_const". So
> 'parent->name', 'parent->fw_name' and 'dst' should be freed.
>
> Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
> ---
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index aa51756..85c4d3f 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -3435,6 +3435,7 @@ static int clk_cpy_name(const char **dst_p, const char *src, bool must_exist)
> if (!dst)
> return -ENOMEM;
>
> + kfree_const(dst);
So you are now returning a freed pointer in dst_p?
> return 0;
> }
>
> @@ -3491,6 +3492,8 @@ static int clk_core_populate_parent_map(struct clk_core *core)
> kfree_const(parents[i].name);
> kfree_const(parents[i].fw_name);
> } while (--i >= 0);
> + kfree_const(parent->name);
> + kfree_const(parent->fw_name);
Both of them were just freed in the loop above, no?
thanks,
--
js
suse labs
next prev parent reply other threads:[~2019-06-05 6:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-31 1:14 Gen Zhang
2019-06-05 6:38 ` Jiri Slaby [this message]
2019-06-05 16:00 ` Gen Zhang
2019-06-06 20:16 ` Stephen Boyd
2019-06-07 1:52 ` Gen Zhang
2019-06-07 9:10 ` Jiri Slaby
2019-06-07 12:07 ` Gen Zhang
-- strict thread matches above, loose matches on Subject: below --
2019-05-27 14:04 Gen Zhang
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=eb8e2d33-e8f7-93a5-c8bc-98731c0d63b6@suse.cz \
--to=jslaby@suse.cz \
--cc=blackgod016574@gmail.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®