提交 eb758de6 编写于 作者: A Axel Lin 提交者: Mark Brown

regulator: lp8788-buck: Silence build warning

This driver use id as array index, thus add bounder checking for id.

This patch fixes below build warning:
drivers/regulator/lp8788-buck.c: In function 'lp8788_buck_probe':
drivers/regulator/lp8788-buck.c:490:8: warning: array subscript is above array bounds [-Warray-bounds]
drivers/regulator/lp8788-buck.c:489:63: warning: array subscript is above array bounds [-Warray-bounds]
Reported-by: NFengguang Wu <fengguang.wu@intel.com>
Signed-off-by: NAxel Lin <axel.lin@ingics.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 b9bb0911
......@@ -474,7 +474,7 @@ static int lp8788_init_dvs(struct platform_device *pdev,
u8 default_dvs_mode[] = { LP8788_BUCK1_DVS_I2C, LP8788_BUCK2_DVS_I2C };
/* no dvs for buck3, 4 */
if (id == BUCK3 || id == BUCK4)
if (id > BUCK2)
return 0;
/* no dvs platform data, then dvs will be selected by I2C registers */
......@@ -505,6 +505,9 @@ static int lp8788_buck_probe(struct platform_device *pdev)
struct regulator_dev *rdev;
int ret;
if (id >= LP8788_NUM_BUCKS)
return -EINVAL;
buck = devm_kzalloc(&pdev->dev, sizeof(struct lp8788_buck), GFP_KERNEL);
if (!buck)
return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册