Browse Source

generic-adc-battery: Pointer math issue in gab_probe()

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>
Dan Carpenter 12 years ago
parent
commit
a77d60aec7
1 changed files with 2 additions and 1 deletions
  1. 2 1
      drivers/power/generic-adc-battery.c

+ 2 - 1
drivers/power/generic-adc-battery.c

@@ -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