]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
platform/x86: uniwill-laptop: Fix signedness bug
authorEthan Tidmore <ethantidmore06@gmail.com>
Fri, 3 Apr 2026 07:09:28 +0000 (02:09 -0500)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 9 Apr 2026 12:01:11 +0000 (15:01 +0300)
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>
Link: https://patch.msgid.link/20260403070928.802196-1-ethantidmore06@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/uniwill/uniwill-acpi.c

index faade4cf08bece45e9b10b0ea7fcc57d919502e8..945df509263715639b119638281a464a5b61a456 100644 (file)
@@ -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);