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: <ZRWHg9r9RsuOpedS@yilunxu-OptiPlex-7050>
Date:   Thu, 28 Sep 2023 22:02:43 +0800
From:   Xu Yilun <yilun.xu@...ux.intel.com>
To:     Jinjie Ruan <ruanjinjie@...wei.com>
Cc:     mdf@...nel.org, hao.wu@...el.com, yilun.xu@...el.com,
        trix@...hat.com, russell.h.weight@...el.com,
        linux-fpga@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH RESEND] fpga: region: Fix possible memory leak in
 fpga_region_register_full()

On Thu, Sep 28, 2023 at 05:16:36PM +0800, Jinjie Ruan wrote:
> If device_register() fails in fpga_region_register_full(), the region
> allocated by kzalloc() and the id allocated by ida_alloc() also need be
> freed otherwise will cause memory leak.

How did you observe the memory leak? Please help provide some trace.

Thanks,
Yilun

> 
> Fixes: 8886a579744f ("fpga: region: Use standard dev_release for class driver")
> Signed-off-by: Jinjie Ruan <ruanjinjie@...wei.com>
> ---
>  drivers/fpga/fpga-region.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c
> index b364a929425c..9dc6314976ef 100644
> --- a/drivers/fpga/fpga-region.c
> +++ b/drivers/fpga/fpga-region.c
> @@ -228,12 +228,13 @@ fpga_region_register_full(struct device *parent, const struct fpga_region_info *
>  
>  	ret = device_register(&region->dev);
>  	if (ret) {
> -		put_device(&region->dev);
> -		return ERR_PTR(ret);
> +		goto err_put_device;
>  	}
>  
>  	return region;
>  
> +err_put_device:
> +	put_device(&region->dev);
>  err_remove:
>  	ida_free(&fpga_region_ida, id);
>  err_free:
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ