generic-adc-battery: Pointer math issue in gab_probe()
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 29 Sep 2012 07:13:46 +0000 (10:13 +0300)
committerAnton Vorontsov <anton.vorontsov@linaro.org>
Sat, 17 Nov 2012 02:36:11 +0000 (18:36 -0800)
psy->properties is an enum (32 bit type) so adding sizeof() puts us four
times further along than we intended.  It should be cast to a char pointer
before doing the math.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
drivers/power/generic-adc-battery.c

index 4a00ef7a8795ae6da3ada89e32847f3456ef274a..ecbf672a35db1bbb71daefca3a02b4574119ed2d 100644 (file)
@@ -279,7 +279,8 @@ static int __devinit gab_probe(struct platform_device *pdev)
        }
 
        memcpy(psy->properties, gab_props, sizeof(gab_props));
-       properties = psy->properties + sizeof(gab_props);
+       properties = (enum power_supply_property *)
+                               ((char *)psy->properties + sizeof(gab_props));
 
        /*
         * getting channel from iio and copying the battery properties