From: Dan Carpenter <dan.carpenter@oracle.com>
To: Anton Vorontsov <cbou@mail.ru>,
anish kumar <anish198519851985@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] power: battery: pointer math issue in gab_probe()
Date: Sat, 29 Sep 2012 10:13:46 +0300 [thread overview]
Message-ID: <20120929071346.GE10993@elgon.mountain> (raw)
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
next reply other threads:[~2012-09-29 7:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-29 7:13 Dan Carpenter [this message]
2012-09-30 4:08 ` [patch] power: battery: pointer math issue in gab_probe() 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120929071346.GE10993@elgon.mountain \
--to=dan.carpenter@oracle.com \
--cc=anish198519851985@gmail.com \
--cc=cbou@mail.ru \
--cc=dwmw2@infradead.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox