[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20130106223728.GA19097@lizard.sbx05280.losalca.wayport.net>
Date: Sun, 6 Jan 2013 14:37:29 -0800
From: Anton Vorontsov <anton@...msg.org>
To: Nickolai Zeldovich <nickolai@...il.mit.edu>
Cc: David Woodhouse <dwmw2@...radead.org>,
Ashish Jangam <ashish.jangam@...tcummins.com>,
Fabio Estevam <fabio.estevam@...escale.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drivers/power/da9052-battery.c: avoid out-of-range array
access
On Sat, Jan 05, 2013 at 02:14:51PM -0500, Nickolai Zeldovich wrote:
> Avoid accessing vc_tbl_ref[3], which is one past the end of that array,
> in da9052_determine_vc_tbl_index(), by adjusting the loop bound.
>
> Signed-off-by: Nickolai Zeldovich <nickolai@...il.mit.edu>
> ---
Applied, thanks!
> drivers/power/da9052-battery.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/da9052-battery.c b/drivers/power/da9052-battery.c
> index 3c5c2e4..08193fe 100644
> --- a/drivers/power/da9052-battery.c
> +++ b/drivers/power/da9052-battery.c
> @@ -337,7 +337,7 @@ static unsigned char da9052_determine_vc_tbl_index(unsigned char adc_temp)
> if (adc_temp > vc_tbl_ref[DA9052_VC_TBL_REF_SZ - 1])
> return DA9052_VC_TBL_REF_SZ - 1;
>
> - for (i = 0; i < DA9052_VC_TBL_REF_SZ; i++) {
> + for (i = 0; i < DA9052_VC_TBL_REF_SZ - 1; i++) {
> if ((adc_temp > vc_tbl_ref[i]) &&
> (adc_temp <= DA9052_MEAN(vc_tbl_ref[i], vc_tbl_ref[i + 1])))
> return i;
> --
> 1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists