提交 89b135ba 编写于 作者: D Dan Carpenter 提交者: Sebastian Reichel

power: supply: adp5061: Fix a couple off by ones

We end up reading one element beyond the end of the adp5061_vmax[] array
here.

Fixes: fe8e81b7 ("adp5061: New driver for ADP5061 I2C battery charger")
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NSebastian Reichel <sebastian.reichel@collabora.co.uk>
上级 7914c676
......@@ -266,8 +266,8 @@ static int adp5061_get_max_voltage(struct adp5061_state *st,
return ret;
regval = ((regval & ADP5061_TERM_SET_VTRM_MSK) >> 2) - 0x0F;
if (regval > ARRAY_SIZE(adp5061_vmax))
regval = ARRAY_SIZE(adp5061_vmax);
if (regval >= ARRAY_SIZE(adp5061_vmax))
regval = ARRAY_SIZE(adp5061_vmax) - 1;
val->intval = adp5061_vmax[regval] * 1000;
......@@ -344,8 +344,8 @@ static int adp5061_get_const_chg_current(struct adp5061_state *st,
return ret;
regval = ((regval & ADP5061_CHG_CURR_ICHG_MSK) >> 2);
if (regval > ARRAY_SIZE(adp5061_const_ichg))
regval = ARRAY_SIZE(adp5061_const_ichg);
if (regval >= ARRAY_SIZE(adp5061_const_ichg))
regval = ARRAY_SIZE(adp5061_const_ichg) - 1;
val->intval = adp5061_const_ichg[regval] * 1000;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册