Skip to content

Commit

Permalink
regulator: max8907: fix use of possibly NULL idata
Browse files Browse the repository at this point in the history
If a regulator is not used by a board, it's quite legitimate not to
provide platform data or a device tree node to configure it (i.e.
regulator_init_data). In that case, during MAX8907 regulator's
probe(), the idata variable will be NULL for that regulator. Prevent
dereferincing it.

If the MBATT regulator's init_data is not specified, or no name was
specified in the constraints, the regulator will be named based on
the regulator descriptor, so initialize mbatt_rail_name from there.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Stephen Warren authored and Mark Brown committed Aug 28, 2012
1 parent dedae95 commit 5fc72f5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/regulator/max8907-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,10 @@ static __devinit int max8907_regulator_probe(struct platform_device *pdev)

switch (pmic->desc[i].id) {
case MAX8907_MBATT:
mbatt_rail_name = idata->constraints.name;
if (idata && idata->constraints.name)
mbatt_rail_name = idata->constraints.name;
else
mbatt_rail_name = pmic->desc[i].name;
break;
case MAX8907_BBAT:
case MAX8907_SDBY:
Expand Down

0 comments on commit 5fc72f5

Please sign in to comment.