Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bq27x00_battery: Fix error return code

Initialize return variable before exiting on an error path.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}

// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>

authored by

Julia Lawall and committed by
Anton Vorontsov
f7760995 d2941651

+2 -1
+2 -1
drivers/power/bq27x00_battery.c
··· 814 814 di->bat.name = name; 815 815 di->bus.read = &bq27x00_read_i2c; 816 816 817 - if (bq27x00_powersupply_init(di)) 817 + retval = bq27x00_powersupply_init(di); 818 + if (retval) 818 819 goto batt_failed_3; 819 820 820 821 i2c_set_clientdata(client, di);