lkml.org 
[lkml]   [2012]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch] power: 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>
---
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

\
 
 \ /
  Last update: 2012-09-29 09:41    [W:1.414 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site