From: Srinivas Kandagatla <srini@kernel.org>
To: Haotian Zhang <vulab@iscas.ac.cn>, srini@kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nvmem: core: fix GPIO descriptor resource leak
Date: Mon, 10 Nov 2025 07:39:07 +0000 [thread overview]
Message-ID: <4472655b-a7a1-4bb7-a05c-6762aa06cb95@kernel.org> (raw)
In-Reply-To: <20251028165526.534-1-vulab@iscas.ac.cn>
On 10/28/25 4:55 PM, Haotian Zhang wrote:
> The driver calls gpiod_get_optional() in nvmem_register() but never
> calls gpiod_put() in nvmem_device_release() or in the register error
> path. This leads to a GPIO descriptor resource leak.
>
> Add gpiod_put() in nvmem_device_release() and in the register error
> path to fix the resource leak.
>
> Fixes: 2a127da461a9 ("nvmem: add support for the write-protect pin")
Missing cc stable
--srini> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
> drivers/nvmem/core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 387c88c55259..597598db88f4 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -1043,6 +1043,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
> if (config->compat)
> nvmem_sysfs_remove_compat(nvmem, config);
> err_put_device:
> + gpiod_put(nvmem->wp_gpio);
> put_device(&nvmem->dev);
>
> return ERR_PTR(rval);
> @@ -1062,6 +1063,7 @@ static void nvmem_device_release(struct kref *kref)
>
> nvmem_device_remove_all_cells(nvmem);
> nvmem_destroy_layout(nvmem);
> + gpiod_put(nvmem->wp_gpio);
> device_unregister(&nvmem->dev);
> }
>
prev parent reply other threads:[~2025-11-10 7:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 16:55 Haotian Zhang
2025-11-10 7:39 ` Srinivas Kandagatla [this message]
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=4472655b-a7a1-4bb7-a05c-6762aa06cb95@kernel.org \
--to=srini@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vulab@iscas.ac.cn \
/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®