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] [thread-next>] [day] [month] [year] [list]
Message-ID: <3ed83017-f3de-b6b0-91d0-d9075ad9eed5@microchip.com>
Date:   Wed, 29 Apr 2020 16:15:56 +0200
From:   Nicolas Ferre <nicolas.ferre@...rochip.com>
To:     Dejin Zheng <zhengdejin5@...il.com>, <davem@...emloft.net>,
        <paul.walmsley@...ive.com>, <palmer@...belt.com>,
        <yash.shah@...ive.com>, <netdev@...r.kernel.org>
CC:     <linux-kernel@...r.kernel.org>,
        Andy Shevchenko <andy.shevchenko@...il.com>
Subject: Re: [PATCH net v2] net: macb: fix an issue about leak related system
 resources

On 29/04/2020 at 15:56, Dejin Zheng wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> A call of the function macb_init() can fail in the function
> fu540_c000_init. The related system resources were not released
> then. use devm_platform_ioremap_resource() to replace ioremap()
> to fix it.
> 
> Fixes: c218ad559020ff9 ("macb: Add support for SiFive FU540-C000")
> Cc: Andy Shevchenko <andy.shevchenko@...il.com>
> Reviewed-by: Yash Shah <yash.shah@...ive.com>
> Signed-off-by: Dejin Zheng <zhengdejin5@...il.com>
> ---
> v1 -> v2:
>          - Nicolas and Andy suggest use devm_platform_ioremap_resource()
>            to repalce devm_ioremap() to fix this issue. Thanks Nicolas
>            and Andy.
>          - Yash help me to review this patch, Thanks Yash!
> 
>   drivers/net/ethernet/cadence/macb_main.c | 8 +-------
>   1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index a0e8c5bbabc0..99354e327d1f 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -4172,13 +4172,7 @@ static int fu540_c000_clk_init(struct platform_device *pdev, struct clk **pclk,
> 
>   static int fu540_c000_init(struct platform_device *pdev)
>   {
> -       struct resource *res;
> -
> -       res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> -       if (!res)
> -               return -ENODEV;
> -
> -       mgmt->reg = ioremap(res->start, resource_size(res));
> +       mgmt->reg = devm_platform_ioremap_resource(pdev, 1);
>          if (!mgmt->reg)

Is your test valid then?

Please use:
if (IS_ERR(base))
    return PTR_ERR(base);
As advised by:
lib/devres.c:156

Regards,
   Nicolas

>                  return -ENOMEM;
> 
> --
> 2.25.0
> 


-- 
Nicolas Ferre

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ