From: Peng Fan <peng.fan@oss.nxp.com>
To: Hao Luo <m202171776@hust.edu.cn>, Abel Vesa <abelvesa@kernel.org>,
Peng Fan <peng.fan@nxp.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>,
Anson Huang <Anson.Huang@nxp.com>
Cc: hust-os-kernel-patches@googlegroups.com,
Dongliang Mu <dzm91@hust.edu.cn>,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clk: imx: clk-imx8mn: fix memory leak in imx8mn_clocks_probe
Date: Wed, 12 Apr 2023 17:07:22 +0800 [thread overview]
Message-ID: <5704f388-3982-4706-9d38-5110b1cc2bbf@oss.nxp.com> (raw)
In-Reply-To: <20230411015107.2645-1-m202171776@hust.edu.cn>
On 4/11/2023 9:51 AM, Hao Luo wrote:
> Use devm_of_iomap() instead of of_iomap() to automatically handle
> the unused ioremap region.
>
> If any error occurs, regions allocated by kzalloc() will leak,
> but using devm_kzalloc() instead will automatically free the memory
> using devm_kfree().
>
> Fixes: daeb14545514 ("clk: imx: imx8mn: Switch to clk_hw based API")
> Fixes: 96d6392b54db ("clk: imx: Add support for i.MX8MN clock driver")
> Signed-off-by: Hao Luo <m202171776@hust.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
LGTM: Reviewed-by: Peng Fan <peng.fan@nxp.com>
> ---
> The issue is discovered by static analysis, and the patch is not tested yet.
Please add Version change log in future patches.
Regards,
Peng.
> ---
> drivers/clk/imx/clk-imx8mn.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clk/imx/clk-imx8mn.c b/drivers/clk/imx/clk-imx8mn.c
> index a042ed3a9d6c..569b2abf4052 100644
> --- a/drivers/clk/imx/clk-imx8mn.c
> +++ b/drivers/clk/imx/clk-imx8mn.c
> @@ -323,7 +323,7 @@ static int imx8mn_clocks_probe(struct platform_device *pdev)
> void __iomem *base;
> int ret;
>
> - clk_hw_data = kzalloc(struct_size(clk_hw_data, hws,
> + clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws,
> IMX8MN_CLK_END), GFP_KERNEL);
> if (WARN_ON(!clk_hw_data))
> return -ENOMEM;
> @@ -340,10 +340,10 @@ static int imx8mn_clocks_probe(struct platform_device *pdev)
> hws[IMX8MN_CLK_EXT4] = imx_get_clk_hw_by_name(np, "clk_ext4");
>
> np = of_find_compatible_node(NULL, NULL, "fsl,imx8mn-anatop");
> - base = of_iomap(np, 0);
> + base = devm_of_iomap(dev, np, 0, NULL);
> of_node_put(np);
> - if (WARN_ON(!base)) {
> - ret = -ENOMEM;
> + if (WARN_ON(IS_ERR(base))) {
> + ret = PTR_ERR(base);
> goto unregister_hws;
> }
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-04-12 9:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-11 1:51 [PATCH] clk: imx: clk-imx8mn: fix memory leak in imx8mn_clocks_probe Hao Luo
2023-04-12 9:07 ` Peng Fan [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-04-07 1:44 Hao Luo
2023-04-07 2:43 ` Peng Fan
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=5704f388-3982-4706-9d38-5110b1cc2bbf@oss.nxp.com \
--to=peng.fan@oss.nxp.com \
--cc=Anson.Huang@nxp.com \
--cc=abelvesa@kernel.org \
--cc=dzm91@hust.edu.cn \
--cc=festevam@gmail.com \
--cc=hust-os-kernel-patches@googlegroups.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=m202171776@hust.edu.cn \
--cc=mturquette@baylibre.com \
--cc=peng.fan@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=sboyd@kernel.org \
--cc=shawnguo@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;
as well as URLs for NNTP newsgroup(s).