Commit 98652efc authored by Christoph Fritz's avatar Christoph Fritz Committed by Richard Purdie

leds: 88pm860x - fix checking in probe function

Improve device and platform data checks in probe function.
Signed-off-by: default avatarHaojian Zhuang <haojian.zhuang@marvell.com>
Signed-off-by: default avatarChristoph Fritz <chf.fritz@googlemail.com>
Signed-off-by: default avatarRichard Purdie <rpurdie@linux.intel.com>
parent b1cdc467
...@@ -256,8 +256,10 @@ static int pm860x_led_probe(struct platform_device *pdev) ...@@ -256,8 +256,10 @@ static int pm860x_led_probe(struct platform_device *pdev)
if (pdev->dev.parent->platform_data) { if (pdev->dev.parent->platform_data) {
pm860x_pdata = pdev->dev.parent->platform_data; pm860x_pdata = pdev->dev.parent->platform_data;
pdata = pm860x_pdata->led; pdata = pm860x_pdata->led;
} else } else {
pdata = NULL; dev_err(&pdev->dev, "missing platform data\n");
return -EINVAL;
}
data = kzalloc(sizeof(struct pm860x_led), GFP_KERNEL); data = kzalloc(sizeof(struct pm860x_led), GFP_KERNEL);
if (data == NULL) if (data == NULL)
...@@ -268,8 +270,11 @@ static int pm860x_led_probe(struct platform_device *pdev) ...@@ -268,8 +270,11 @@ static int pm860x_led_probe(struct platform_device *pdev)
data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion; data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion;
data->iset = pdata->iset; data->iset = pdata->iset;
data->port = __check_device(pdata, data->name); data->port = __check_device(pdata, data->name);
if (data->port < 0) if (data->port < 0) {
dev_err(&pdev->dev, "check device failed\n");
kfree(data);
return -EINVAL; return -EINVAL;
}
data->current_brightness = 0; data->current_brightness = 0;
data->cdev.name = data->name; data->cdev.name = data->name;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment