Unverified Commit 6b0567dc authored by Ethan Tidmore's avatar Ethan Tidmore Committed by Ilpo Järvinen
Browse files

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: 03ae0a0d ("platform/x86: uniwill-laptop: Implement USB-C power priority setting")
Signed-off-by: default avatarEthan Tidmore <ethantidmore06@gmail.com>
Link: https://patch.msgid.link/20260403070928.802196-1-ethantidmore06@gmail.com


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent f8fd138c
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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);