[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <DU0PR04MB9417B63DE97D4A2A77B4176C88969@DU0PR04MB9417.eurprd04.prod.outlook.com>
Date: Fri, 7 Apr 2023 02:43:02 +0000
From: Peng Fan <peng.fan@....com>
To: Hao Luo <m202171776@...t.edu.cn>, Abel Vesa <abelvesa@...nel.org>,
Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>,
Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>,
dl-linux-imx <linux-imx@....com>
CC: "hust-os-kernel-patches@...glegroups.com"
<hust-os-kernel-patches@...glegroups.com>,
"linux-clk@...r.kernel.org" <linux-clk@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] clk: imx: clk-imx8mn: fix memory leak in
imx8mn_clocks_probe
> Subject: [PATCH] clk: imx: clk-imx8mn: fix memory leak in
> imx8mn_clocks_probe
>
> Use devm_platform_ioremap_resource() 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().
>
> Signed-off-by: Hao Luo <m202171776@...t.edu.cn>
> ---
> 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..b054412f6373 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_platform_ioremap_resource(pdev, 0);
This is wrong. Here is to map anatop register space, not ccm register space.
Regards,
Peng.
> of_node_put(np);
> - if (WARN_ON(!base)) {
> - ret = -ENOMEM;
> + if (WARN_ON(IS_ERR(base))) {
> + ret = PTR_ERR(base);
> goto unregister_hws;
> }
>
> --
> 2.34.1
Powered by blists - more mailing lists