Messages in this thread | | | Date | Fri, 14 Apr 2023 10:02:19 +0800 (GMT+08:00) | From | 周师德 <> | Subject | Re: Re: [PATCH] clk: imx: clk-imx8mm: fix memory leak issue in 'imx8mm_clocks_probe' |
| |
> -----原始邮件----- > 发件人: "Stephen Boyd" <sboyd@kernel.org> > 发送时间: 2023-04-14 03:06:59 (星期五) > 收件人: "Abel Vesa" <abelvesa@kernel.org>, "Bai Ping" <ping.bai@nxp.com>, "Fabio Estevam" <festevam@gmail.com>, "Michael Turquette" <mturquette@baylibre.com>, "NXP Linux Team" <linux-imx@nxp.com>, "Peng Fan" <peng.fan@nxp.com>, "Pengutronix Kernel Team" <kernel@pengutronix.de>, "Sascha Hauer" <s.hauer@pengutronix.de>, "Shawn Guo" <shawnguo@kernel.org>, "Zhou Shide" <u201911681@hust.edu.cn> > 抄送: hust-os-kernel-patches@googlegroups.com, "Zhou Shide" <u201911681@hust.edu.cn>, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "Hao Luo" <m202171776@hust.edu.cn> > 主题: Re: [PATCH] clk: imx: clk-imx8mm: fix memory leak issue in 'imx8mm_clocks_probe' > > Quoting Zhou Shide (2023-04-12 20:24:39) > > The function imx8mm_clocks_probe() has two main issues: > > - The of_iomap() function may cause a memory leak. > > - Memory allocated for 'clk_hw_data' may not be freed properly > > in some paths. > > > > To fix these issues, this commit replaces the use of of_iomap() > > with devm_of_iomap() and replaces kzalloc() with devm_kzalloc(). > > This ensures that all memory is properly managed and automatically > > freed when the device is removed. > > > > In addition, when devm_of_iomap() allocates memory with an error, > > it will first jump to label "unregister_hws" and > > then return PTR_ ERR(base). > > > > Fixes: 9c71f9ea35d7 ("clk: imx: imx8mm: Switch to clk_hw based API") > > Fixes: ba5625c3e272 ("clk: imx: Add clock driver support for imx8mm") > > Signed-off-by: Zhou Shide <u201911681@hust.edu.cn> > > --- > > The issue is discovered by static analysis, and the patch is not tested yet. > > And you're not coordinating with each other? What do you mean by "coordinating with each other"?
regards, Zhou Shide
| |