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>] [day] [month] [year] [list]
Message-ID: <20251028165526.534-1-vulab@iscas.ac.cn>
Date: Wed, 29 Oct 2025 00:55:26 +0800
From: Haotian Zhang <vulab@...as.ac.cn>
To: srini@...nel.org
Cc: linux-kernel@...r.kernel.org,
	Haotian Zhang <vulab@...as.ac.cn>
Subject: [PATCH] nvmem: core: fix GPIO descriptor resource leak

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")
Signed-off-by: Haotian Zhang <vulab@...as.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);
 }
 
-- 
2.50.1.windows.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ