lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e336d1d4-74e9-282b-1b80-e5f5617fab06@oss.nxp.com>
Date:   Fri, 28 Apr 2023 15:53:44 +0800
From:   Peng Fan <peng.fan@....nxp.com>
To:     Yuxing Liu <lyx2022@...t.edu.cn>, Abel Vesa <abelvesa@...nel.org>,
        Peng Fan <peng.fan@....com>,
        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>,
        NXP Linux Team <linux-imx@....com>,
        Anson Huang <Anson.Huang@....com>
Cc:     hust-os-kernel-patches@...glegroups.com,
        Dongliang Mu <dzm91@...t.edu.cn>, linux-clk@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] clk: imx: clk-imx8mp: use dev_ managed memory to
 avoid memory leak in imx8mp_clocks_probe()



On 4/24/2023 5:23 PM, Yuxing Liu wrote:
> Replace of_iomap() and kzalloc() with devm_of_iomap() and devm_kzalloc()
> which can automatically release the related memory when the device
> or driver is disassembled or unloaded to avoid potential memory leak.

What do you mean "disassembled"? The i.MX8MP is an SoC which has Clock
IP built in the device.

Regards,
Peng.

> 
> In this case,iounmap(anatop_base) in line 427,433 are removed
> as manual release is not required.
> 
> Fixes: 9c140d992676 ("clk: imx: Add support for i.MX8MP clock driver")
> Signed-off-by: Yuxing Liu <lyx2022@...t.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@...t.edu.cn>
> ---
> This issue is found by static analysis and remains untested.
> ---
>   drivers/clk/imx/clk-imx8mp.c | 16 ++++++----------
>   1 file changed, 6 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/clk/imx/clk-imx8mp.c b/drivers/clk/imx/clk-imx8mp.c
> index 3253589851ff..353d58b665f9 100644
> --- a/drivers/clk/imx/clk-imx8mp.c
> +++ b/drivers/clk/imx/clk-imx8mp.c
> @@ -416,23 +416,19 @@ static int imx8mp_clocks_probe(struct platform_device *pdev)
>   	void __iomem *anatop_base, *ccm_base;
>   
>   	np = of_find_compatible_node(NULL, NULL, "fsl,imx8mp-anatop");
> -	anatop_base = of_iomap(np, 0);
> +	anatop_base = devm_of_iomap(dev, np, 0, NULL);
>   	of_node_put(np);
> -	if (WARN_ON(!anatop_base))
> -		return -ENOMEM;
> +	if (WARN_ON(IS_ERR(anatop_base)))
> +		return PTR_ERR(anatop_base);
>   
>   	np = dev->of_node;
>   	ccm_base = devm_platform_ioremap_resource(pdev, 0);
> -	if (WARN_ON(IS_ERR(ccm_base))) {
> -		iounmap(anatop_base);
> +	if (WARN_ON(IS_ERR(ccm_base)))
>   		return PTR_ERR(ccm_base);
> -	}
>   
> -	clk_hw_data = kzalloc(struct_size(clk_hw_data, hws, IMX8MP_CLK_END), GFP_KERNEL);
> -	if (WARN_ON(!clk_hw_data)) {
> -		iounmap(anatop_base);
> +	clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws, IMX8MP_CLK_END), GFP_KERNEL);
> +	if (WARN_ON(!clk_hw_data))
>   		return -ENOMEM;
> -	}
>   
>   	clk_hw_data->num = IMX8MP_CLK_END;
>   	hws = clk_hw_data->hws;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ