From: Perry Hung Date: Fri, 24 Jul 2015 23:02:29 +0000 (-0400) Subject: greybus: battery: fix panic on operation error X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=e619e8505b66229fdf2735ac00891d340111b0a8;p=openwrt%2Fstaging%2Fblogic.git greybus: battery: fix panic on operation error If an operation times out or otherwise returns an error, val->intval should not be set and an error-code should be returned. Fixes a panic on unload while receiving -ENOTCONN. Signed-off-by: Perry Hung Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/battery.c b/drivers/staging/greybus/battery.c index aad174975258..e66623966dc9 100644 --- a/drivers/staging/greybus/battery.c +++ b/drivers/staging/greybus/battery.c @@ -281,7 +281,7 @@ static int get_property(struct power_supply *b, return -EINVAL; } - return 0; + return (val->intval < 0) ? val->intval : 0; } // FIXME - verify this list, odds are some can be removed and others added.