power_supply: Handle missing platform data gracefully
PATCH 1/1 power_supply: Handle missing platform data gracefully
Don't unconditionally dereference the WM97xx core platform data since it may not be present, causing an oops.
Signed-off-by Mark Brown <[email protected]>
--- drivers/power/wm97xx_battery.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
drivers/power/wm97xx_battery.c +8 -2
@@ -175,8 +175,14 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)dev_err (&dev->dev,"Do not pass platform_data through " "wm97xx_bat_set_pdata!\n" );return -EINVAL ; - }else - pdata = wmdata->batt_pdata; + } + +if (!wmdata) { +dev_err (&dev->dev,"No platform data supplied\n" ); +return -EINVAL ; + } + + pdata = wmdata->batt_pdata;if (dev->id !=-1 )return -EINVAL ;
Signature · 1 line
1.6.6
Anton Vorontsov
AppliedQuoted 5 lines · Mark Brown
Don't unconditionally dereference the WM97xx core platform data since it may not be present, causing an oops.
Signed-off-by Mark Brown <[email protected]>---
Applied to battery-2.6.33, thanks!