[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b4699098-afd5-4a1a-aa7f-15949b0d10f7@oracle.com>
Date: Mon, 16 Jun 2025 18:14:49 +0530
From: ALOK TIWARI <alok.a.tiwari@...cle.com>
To: srini@...nel.org, linux-kernel@...r.kernel.org
Cc: darren.kenny@...cle.com
Subject: Re: [PATCH 1/2] nvmem: core: fix memory leak in nvmem_register() on
error path
On 15-06-2025 19:22, Alok Tiwari wrote:
> Ensure that the allocated nvmem structure is freed if device
> registration return error code.
> The missing kfree() caused a memory leak when nvmem_register()
> exited via err_put_device label.
>
> Signed-off-by: Alok Tiwari <alok.a.tiwari@...cle.com>
> ---
> drivers/nvmem/core.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index fd2a9698d1c9..3203524ad49f 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -1044,6 +1044,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
> nvmem_sysfs_remove_compat(nvmem, config);
> err_put_device:
> put_device(&nvmem->dev);
> + kfree(nvmem);
>
> return ERR_PTR(rval);
> }
Please ignore this patch. it is not required.
nvmem_release already handles the cleanup properly.
Thanks,
Alok
Powered by blists - more mailing lists