From: ALOK TIWARI <alok.a.tiwari@oracle.com>
To: srini@kernel.org, linux-kernel@vger.kernel.org
Cc: darren.kenny@oracle.com
Subject: Re: [PATCH 1/2] nvmem: core: fix memory leak in nvmem_register() on error path
Date: Mon, 16 Jun 2025 18:14:49 +0530 [thread overview]
Message-ID: <b4699098-afd5-4a1a-aa7f-15949b0d10f7@oracle.com> (raw)
In-Reply-To: <20250615135212.1356469-1-alok.a.tiwari@oracle.com>
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@oracle.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
next prev parent reply other threads:[~2025-06-16 12:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-15 13:52 Alok Tiwari
2025-06-15 13:52 ` [PATCH 2/2] nvmem: core: Fix typos in comments and MODULE_AUTHOR strings Alok Tiwari
2025-06-16 12:44 ` ALOK TIWARI [this message]
2025-06-27 12:08 ` (subset) [PATCH 1/2] nvmem: core: fix memory leak in nvmem_register() on error path Srinivas Kandagatla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b4699098-afd5-4a1a-aa7f-15949b0d10f7@oracle.com \
--to=alok.a.tiwari@oracle.com \
--cc=darren.kenny@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=srini@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®