提交 1b69d8e3 编写于 作者: A Axel Lin 提交者: Liam Girdwood

max8998: fix off-by-one value range checking

In max8998_list_voltage() and max8998_set_voltage(),
we use ldo as array index of ldo_voltage_map.
Thus the valid range should be 0 .. ARRAY_SIZE(ldo_voltage_map)-1.
Signed-off-by: NAxel Lin <axel.lin@gmail.com>
Acked-by: NKyungmin Park <kyungmin.park@samsung.com>
Acked-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: NLiam Girdwood <lrg@slimlogic.co.uk>
上级 4cc2e393
......@@ -119,7 +119,7 @@ static int max8998_list_voltage(struct regulator_dev *rdev,
int ldo = max8998_get_ldo(rdev);
int val;
if (ldo > ARRAY_SIZE(ldo_voltage_map))
if (ldo >= ARRAY_SIZE(ldo_voltage_map))
return -EINVAL;
desc = ldo_voltage_map[ldo];
......@@ -306,7 +306,7 @@ static int max8998_set_voltage(struct regulator_dev *rdev,
u8 val;
bool en_ramp = false;
if (ldo > ARRAY_SIZE(ldo_voltage_map))
if (ldo >= ARRAY_SIZE(ldo_voltage_map))
return -EINVAL;
desc = ldo_voltage_map[ldo];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册