Skip to contentSkip to conversation

asus-wmi: fix error handling in store_sys_wmi()

PATCH In review Dan Carpenter 2 participants 2 messages Nov 10, 2015 – Nov 11, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 asus-wmi: fix error handling in store_sys_wmi()

The asus_wmi_get_devstate_simple() returns 0-1 on success. In theory according to static checkers, it can return either -EIO or -ENODEV on failure. Currently the error handling code only handles -ENODEV and -EIO is treated as success. Let's make it handle the -EIO error as well.

It's possible that it can't actually return -EIO and this patch is not needed but in that case this patch is harmless and silences a static checker warning so it's still worth it.

drivers/platform/x86/asus-wmi.c +1 -1
index e3a7502..f96f7b8 100644
@@ -1682,7 +1682,7 @@ static ssize_t store_sys_wmi(struct asus_wmi *asus, int devid,
 	int rv, err, value;
 
 	value = asus_wmi_get_devstate_simple(asus, devid);
-	if (value = -ENODEV)	/* Check device presence */
+	if (value < 0)
 		return value;
 
 	rv = parse_arg(buf, count, &value);
#1 lore raw
Quoted 11 lines · Dan Carpenter

The asus_wmi_get_devstate_simple() returns 0-1 on success. In theory according to static checkers, it can return either -EIO or -ENODEV on failure. Currently the error handling code only handles -ENODEV and -EIO is treated as success. Let's make it handle the -EIO error as well.

It's possible that it can't actually return -EIO and this patch is not needed but in that case this patch is harmless and silences a static checker warning so it's still worth it.

Thank you Dan, queued to testing.

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center