From: Mark Brown Date: Wed, 27 Jan 2010 20:43:21 +0000 (+0000) Subject: wm97xx_battery: Handle missing platform data gracefully X-Git-Tag: v2.6.33-rc8~11^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=12b336a8b4ea8652372f88521bf55cef7f5d5283;p=platform%2Fkernel%2Flinux-3.10.git wm97xx_battery: 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 Signed-off-by: Anton Vorontsov --- diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/wm97xx_battery.c index fa39e75..6ea3cb5 100644 --- a/drivers/power/wm97xx_battery.c +++ b/drivers/power/wm97xx_battery.c @@ -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;