mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86: uniwill-laptop: Fix signedness bug
@ 2026-04-03  7:09 Ethan Tidmore
  2026-04-09 13:41 ` Ilpo Järvinen
  0 siblings, 1 reply; 2+ messages in thread
From: Ethan Tidmore @ 2026-04-03  7:09 UTC (permalink / raw)
  To: W_Armin, hansg, ilpo.jarvinen
  Cc: wse, platform-driver-x86, linux-kernel, Ethan Tidmore

The function sysfs_match_string() can return negative error codes and
the variable assigned to it is the enum 'option'. Which could be an
unsigned int due to different compiler implementations.

Assign signed variable 'ret' to sysfs_match_string(), check for error,
then assign ret to option.

Detected by Smatch:
drivers/platform/x86/uniwill/uniwill-acpi.c:919 usb_c_power_priority_store()
warn: unsigned 'option' is never less than zero.

Fixes: 03ae0a0d0973b ("platform/x86: uniwill-laptop: Implement USB-C power priority setting")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 drivers/platform/x86/uniwill/uniwill-acpi.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/uniwill/uniwill-acpi.c b/drivers/platform/x86/uniwill/uniwill-acpi.c
index faade4cf08be..945df5092637 100644
--- a/drivers/platform/x86/uniwill/uniwill-acpi.c
+++ b/drivers/platform/x86/uniwill/uniwill-acpi.c
@@ -915,10 +915,11 @@ static ssize_t usb_c_power_priority_store(struct device *dev,
 	unsigned int value;
 	int ret;
 
-	option = sysfs_match_string(usb_c_power_priority_text, buf);
-	if (option < 0)
-		return option;
+	ret = sysfs_match_string(usb_c_power_priority_text, buf);
+	if (ret < 0)
+		return ret;
 
+	option = ret;
 	value = usb_c_power_priority_value[option];
 
 	guard(mutex)(&data->usb_c_power_priority_lock);
-- 
2.53.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-09 13:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-03  7:09 [PATCH] platform/x86: uniwill-laptop: Fix signedness bug Ethan Tidmore
2026-04-09 13:41 ` Ilpo Järvinen

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®