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]
Date:   Tue, 16 May 2017 15:45:45 +0200
From:   Johan Hovold <johan@...nel.org>
To:     Mika Westerberg <mika.westerberg@...ux.intel.com>
Cc:     Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] nvmem: core: Prevent memory leak when device is
 unregistered

On Mon, May 15, 2017 at 02:13:23PM +0300, Mika Westerberg wrote:
> The nvmem_unregister() calls device_del() for the device but forgets to
> call put_device() to actually release the device object which causes
> that memory to be leaked.
> 
> Fix this by calling device_unregister() for the device intead which also
> calls put_device() for the device releasing it eventually.

I was gonna suggest that you fix up the related leaks in the
registration error paths as well, but since they are really distinct I
just submitted a patch to fix those up separately instead (kfree was
being just instead of put_device and the device was never deregistered
on late probe errors).

> Signed-off-by: Mika Westerberg <mika.westerberg@...ux.intel.com>
> ---
>  drivers/nvmem/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 8c830a80a648..112c8072e0f3 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -528,7 +528,7 @@ int nvmem_unregister(struct nvmem_device *nvmem)
>  		device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom);
>  
>  	nvmem_device_remove_all_cells(nvmem);
> -	device_del(&nvmem->dev);
> +	device_unregister(&nvmem->dev);

Might be cleaner to use an explicit call to put_device() here since the
driver currently does not use device_register().

>  
>  	return 0;
>  }

Thanks,
Johan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ