From: Thierry Reding <thierry.reding@gmail.com>
To: Yuan Can <yuancan@huawei.com>
Cc: pdeschrijver@nvidia.com, pgaikwad@nvidia.com,
mturquette@baylibre.com, sboyd@kernel.org, jonathanh@nvidia.com,
mperttunen@nvidia.com, tomeu.vizoso@collabora.com,
linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH] clk: tegra: tegra124-emc: Fix potential memory leak
Date: Wed, 5 Apr 2023 14:38:49 +0200 [thread overview]
Message-ID: <ZC1r2esSZkqEjRVr@orome> (raw)
In-Reply-To: <20221209094124.71043-1-yuancan@huawei.com>
[-- Attachment #1: Type: text/plain, Size: 1302 bytes --]
On Fri, Dec 09, 2022 at 09:41:24AM +0000, Yuan Can wrote:
> The tegra and tegra needs to be freed in the error handling path, otherwise
> it will be leaked.
>
> Fixes: 2db04f16b589 ("clk: tegra: Add EMC clock driver")
> Signed-off-by: Yuan Can <yuancan@huawei.com>
> ---
> drivers/clk/tegra/clk-tegra124-emc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/clk/tegra/clk-tegra124-emc.c b/drivers/clk/tegra/clk-tegra124-emc.c
> index 219c80653dbd..2a6db0434281 100644
> --- a/drivers/clk/tegra/clk-tegra124-emc.c
> +++ b/drivers/clk/tegra/clk-tegra124-emc.c
> @@ -464,6 +464,7 @@ static int load_timings_from_dt(struct tegra_clk_emc *tegra,
> err = load_one_timing_from_dt(tegra, timing, child);
> if (err) {
> of_node_put(child);
> + kfree(tegra->timings);
> return err;
> }
>
> @@ -515,6 +516,7 @@ struct clk *tegra124_clk_register_emc(void __iomem *base, struct device_node *np
> err = load_timings_from_dt(tegra, node, node_ram_code);
> if (err) {
> of_node_put(node);
> + kfree(tegra);
> return ERR_PTR(err);
> }
> }
Don't we need another kfree(tegra) in case the clk_register() fails? We
could do that as a follow-up and this patch isn't wrong, so:
Acked-by: Thierry Reding <treding@nvidia.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-04-05 12:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-09 9:41 [PATCH] clk: tegra: tegra124-emc: Fix potential memory leak Yuan Can
2023-02-10 23:23 ` Stephen Boyd
2023-04-05 12:38 ` Thierry Reding [this message]
2023-06-15 1:26 ` Stephen Boyd
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=ZC1r2esSZkqEjRVr@orome \
--to=thierry.reding@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mperttunen@nvidia.com \
--cc=mturquette@baylibre.com \
--cc=pdeschrijver@nvidia.com \
--cc=pgaikwad@nvidia.com \
--cc=sboyd@kernel.org \
--cc=tomeu.vizoso@collabora.com \
--cc=yuancan@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox