Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 963406ff authored by Andrzej Hajda's avatar Andrzej Hajda Committed by Darren Hart
Browse files

sony-laptop: Fix handling sony_nc_hotkeys_decode result

sony_nv_hotkeys_decode can return a negative value. real_ev is a u32 variable.
The check for real_ev > 0 is incorrect.

Use an intermediate ret variable.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107



Signed-off-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
[dvhart: clarify commit msg, drop superfluous else block]
Signed-off-by: default avatarDarren Hart <dvhart@linux.intel.com>
parent daea5a65
Loading
Loading
Loading
Loading
+7 −6
Original line number Original line Diff line number Diff line
@@ -1204,6 +1204,8 @@ static void sony_nc_notify(struct acpi_device *device, u32 event)
{
{
	u32 real_ev = event;
	u32 real_ev = event;
	u8 ev_type = 0;
	u8 ev_type = 0;
	int ret;

	dprintk("sony_nc_notify, event: 0x%.2x\n", event);
	dprintk("sony_nc_notify, event: 0x%.2x\n", event);


	if (event >= 0x90) {
	if (event >= 0x90) {
@@ -1225,13 +1227,12 @@ static void sony_nc_notify(struct acpi_device *device, u32 event)
		case 0x0100:
		case 0x0100:
		case 0x0127:
		case 0x0127:
			ev_type = HOTKEY;
			ev_type = HOTKEY;
			real_ev = sony_nc_hotkeys_decode(event, handle);
			ret = sony_nc_hotkeys_decode(event, handle);


			if (real_ev > 0)
			if (ret > 0) {
				sony_laptop_report_input_event(real_ev);
				sony_laptop_report_input_event(ret);
			else
				real_ev = ret;
				/* restore the original event for reporting */
			}
				real_ev = event;


			break;
			break;