public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] power: battery: pointer math issue in gab_probe()
@ 2012-09-29  7:13 Dan Carpenter
  2012-09-30  4:08 ` anish kumar
  2012-11-17  2:36 ` Anton Vorontsov
  0 siblings, 2 replies; 7+ messages in thread
From: Dan Carpenter @ 2012-09-29  7:13 UTC (permalink / raw)
  To: Anton Vorontsov, anish kumar
  Cc: David Woodhouse, linux-kernel, kernel-janitors

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>
---
Casting to void * would also work on GCC, at least.

diff --git a/drivers/power/generic-adc-battery.c b/drivers/power/generic-adc-battery.c
index 9bdf444..776f118 100644
--- a/drivers/power/generic-adc-battery.c
+++ b/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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-11-17  2:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-29  7:13 [patch] power: battery: pointer math issue in gab_probe() Dan Carpenter
2012-09-30  4:08 ` anish kumar
2012-09-30  7:06   ` Dan Carpenter
2012-11-05 12:34   ` anish kumar
2012-11-05 13:09     ` Dan Carpenter
2012-11-05 18:37       ` Anton Vorontsov
2012-11-17  2:36 ` Anton Vorontsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox