aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/lp8788-buck.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-01-09 21:33:06 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-01-10 07:56:57 -0500
commiteb758de6a00f2c1f5694efc503b94d162db99734 (patch)
tree713aa1ab67940f56fafeba72e66cea2a5b3058d6 /drivers/regulator/lp8788-buck.c
parentb9bb09111a4f5dbf8a0bd7df77ec79d3fdf9e5d2 (diff)
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: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/lp8788-buck.c')
-rw-r--r--drivers/regulator/lp8788-buck.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/regulator/lp8788-buck.c b/drivers/regulator/lp8788-buck.c
index 11619493a5cb..ef845c7ac69f 100644
--- a/drivers/regulator/lp8788-buck.c
+++ b/drivers/regulator/lp8788-buck.c
@@ -474,7 +474,7 @@ static int lp8788_init_dvs(struct platform_device *pdev,
474 u8 default_dvs_mode[] = { LP8788_BUCK1_DVS_I2C, LP8788_BUCK2_DVS_I2C }; 474 u8 default_dvs_mode[] = { LP8788_BUCK1_DVS_I2C, LP8788_BUCK2_DVS_I2C };
475 475
476 /* no dvs for buck3, 4 */ 476 /* no dvs for buck3, 4 */
477 if (id == BUCK3 || id == BUCK4) 477 if (id > BUCK2)
478 return 0; 478 return 0;
479 479
480 /* no dvs platform data, then dvs will be selected by I2C registers */ 480 /* 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)
505 struct regulator_dev *rdev; 505 struct regulator_dev *rdev;
506 int ret; 506 int ret;
507 507
508 if (id >= LP8788_NUM_BUCKS)
509 return -EINVAL;
510
508 buck = devm_kzalloc(&pdev->dev, sizeof(struct lp8788_buck), GFP_KERNEL); 511 buck = devm_kzalloc(&pdev->dev, sizeof(struct lp8788_buck), GFP_KERNEL);
509 if (!buck) 512 if (!buck)
510 return -ENOMEM; 513 return -ENOMEM;