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: <20251204080643.1291-1-vulab@iscas.ac.cn>
Date: Thu,  4 Dec 2025 16:06:43 +0800
From: Haotian Zhang <vulab@...as.ac.cn>
To: Srinivas Kandagatla <srini@...nel.org>
Cc: nicholas.johnson-opensource@...look.com.au,
	linux-kernel@...r.kernel.org,
	Haotian Zhang <vulab@...as.ac.cn>
Subject: [PATCH] nvmem: core: fix wrong error codes for missing reg_read/reg_write

When nvmem accessors are NULL, returning -EPERM misrepresents
the condition as a permission error instead of an unsupported
operation.

Return -EOPNOTSUPP when reg_read/reg_write is NULL. Keep -EPERM
only for read-only cases.

Fixes: 3c91ef69a3e9 ("nvmem: check for NULL reg_read and reg_write before dereferencing")
Signed-off-by: Haotian Zhang <vulab@...as.ac.cn>
---
 drivers/nvmem/core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 597598db88f4..93591de530d3 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -232,7 +232,7 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
 	count = round_down(count, nvmem->word_size);
 
 	if (!nvmem->reg_read)
-		return -EPERM;
+		return -EOPNOTSUPP;
 
 	rc = nvmem_reg_read(nvmem, pos, buf, count);
 
@@ -264,7 +264,9 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
 
 	count = round_down(count, nvmem->word_size);
 
-	if (!nvmem->reg_write || nvmem->read_only)
+	if (!nvmem->reg_write)
+		return -EOPNOTSUPP;
+	if (nvmem->read_only)
 		return -EPERM;
 
 	rc = nvmem_reg_write(nvmem, pos, buf, count);
-- 
2.50.1.windows.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ