From: Anton Vorontsov <cbouatmailru@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: anish kumar <anish198519851985@gmail.com>,
David Woodhouse <dwmw2@infradead.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] power: battery: pointer math issue in gab_probe()
Date: Fri, 16 Nov 2012 18:36:49 -0800 [thread overview]
Message-ID: <20121117023649.GA29966@lizard> (raw)
In-Reply-To: <20120929071346.GE10993@elgon.mountain>
On Sat, Sep 29, 2012 at 10:13:46AM +0300, Dan Carpenter wrote:
> 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.
Applied, thanks a lot!
>
> 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
prev parent reply other threads:[~2012-11-17 2:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=20121117023649.GA29966@lizard \
--to=cbouatmailru@gmail.com \
--cc=anish198519851985@gmail.com \
--cc=dan.carpenter@oracle.com \
--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