Skip to content

Commit 6b0567d

Browse files
Ethan Tidmoreij-intel
authored andcommitted
platform/x86: uniwill-laptop: Fix signedness bug
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: 03ae0a0 ("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>
1 parent f8fd138 commit 6b0567d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/platform/x86/uniwill/uniwill-acpi.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -915,10 +915,11 @@ static ssize_t usb_c_power_priority_store(struct device *dev,
915915
unsigned int value;
916916
int ret;
917917

918-
option = sysfs_match_string(usb_c_power_priority_text, buf);
919-
if (option < 0)
920-
return option;
918+
ret = sysfs_match_string(usb_c_power_priority_text, buf);
919+
if (ret < 0)
920+
return ret;
921921

922+
option = ret;
922923
value = usb_c_power_priority_value[option];
923924

924925
guard(mutex)(&data->usb_c_power_priority_lock);

0 commit comments

Comments
 (0)