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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250409-temp-v1-1-9a391d8c60fd@chromium.org>
Date: Wed, 09 Apr 2025 09:13:11 +0000
From: Hsin-Te Yuan <yuanhsinte@...omium.org>
To: "Rafael J. Wysocki" <rafael@...nel.org>, 
 Daniel Lezcano <daniel.lezcano@...aro.org>, Zhang Rui <rui.zhang@...el.com>, 
 Lukasz Luba <lukasz.luba@....com>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org, 
 Hsin-Te Yuan <yuanhsinte@...omium.org>
Subject: [PATCH] thermal: sysfs: Return ENODATA instead of EAGAIN for reads

When userspace nonblocking reads temperature via sysfs, EAGAIN error
returned by thermal driver will confuse user from the usual meaning of
EAGAIN, the read would block. Change to throw ENODATA instead of EAGAIN
to userspace. Also, ENODATA more accurately reflects that data is not
currently available.

Signed-off-by: Hsin-Te Yuan <yuanhsinte@...omium.org>
---
 drivers/thermal/thermal_sysfs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index 24b9055a0b6c515b865e0d7e2db1d0de176ff767..3d1713e053dfb867933d95131f1f2491d2ecd07e 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -40,8 +40,11 @@ temp_show(struct device *dev, struct device_attribute *attr, char *buf)
 
 	ret = thermal_zone_get_temp(tz, &temperature);
 
-	if (ret)
+	if (ret) {
+		if (ret == -EAGAIN)
+			return -ENODATA;
 		return ret;
+	}
 
 	return sprintf(buf, "%d\n", temperature);
 }

---
base-commit: a24588245776dafc227243a01bfbeb8a59bafba9
change-id: 20250409-temp-6ebd13ad0dbd

Best regards,
-- 
Hsin-Te Yuan <yuanhsinte@...omium.org>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ