* [PATCH] fix checking in probe function
@ 2010-04-10 12:40 Christoph Fritz
2010-04-13 0:50 ` Haojian Zhuang
0 siblings, 1 reply; 2+ messages in thread
From: Christoph Fritz @ 2010-04-10 12:40 UTC (permalink / raw)
To: kernel-janitors
Improve device and platform data checks in probe function.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
---
drivers/leds/leds-88pm860x.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c
index 16a60c0..b767710 100644
--- a/drivers/leds/leds-88pm860x.c
+++ b/drivers/leds/leds-88pm860x.c
@@ -256,8 +256,10 @@ static int pm860x_led_probe(struct platform_device *pdev)
if (pdev->dev.parent->platform_data) {
pm860x_pdata = pdev->dev.parent->platform_data;
pdata = pm860x_pdata->led;
- } else
- pdata = NULL;
+ } else {
+ dev_err(&pdev->dev, "missing platform data\n");
+ return -EINVAL;
+ }
data = kzalloc(sizeof(struct pm860x_led), GFP_KERNEL);
if (data = NULL)
@@ -268,8 +270,11 @@ static int pm860x_led_probe(struct platform_device *pdev)
data->i2c = (chip->id = CHIP_PM8606) ? chip->client : chip->companion;
data->iset = pdata->iset;
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;
+ }
data->current_brightness = 0;
data->cdev.name = data->name;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH] fix checking in probe function
2010-04-10 12:40 [PATCH] fix checking in probe function Christoph Fritz
@ 2010-04-13 0:50 ` Haojian Zhuang
0 siblings, 0 replies; 2+ messages in thread
From: Haojian Zhuang @ 2010-04-13 0:50 UTC (permalink / raw)
To: kernel-janitors
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 1754 bytes --]
Yes, kfree() should be used as you mentioned.
I'm OK on your patch.
Thanks
Haojian
-----Original Message-----
From: Christoph Fritz [mailto:chf.fritz@googlemail.com]
Sent: 2010Äê4ÔÂ10ÈÕ 8:41 PM
To: Haojian Zhuang
Cc: Dan Carpenter; Richard Purdie; kernel-janitors@vger.kernel.org
Subject: [PATCH] fix checking in probe function
Improve device and platform data checks in probe function.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
---
drivers/leds/leds-88pm860x.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c
index 16a60c0..b767710 100644
--- a/drivers/leds/leds-88pm860x.c
+++ b/drivers/leds/leds-88pm860x.c
@@ -256,8 +256,10 @@ static int pm860x_led_probe(struct platform_device *pdev)
if (pdev->dev.parent->platform_data) {
pm860x_pdata = pdev->dev.parent->platform_data;
pdata = pm860x_pdata->led;
- } else
- pdata = NULL;
+ } else {
+ dev_err(&pdev->dev, "missing platform data\n");
+ return -EINVAL;
+ }
data = kzalloc(sizeof(struct pm860x_led), GFP_KERNEL);
if (data = NULL)
@@ -268,8 +270,11 @@ static int pm860x_led_probe(struct platform_device *pdev)
data->i2c = (chip->id = CHIP_PM8606) ? chip->client : chip->companion;
data->iset = pdata->iset;
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;
+ }
data->current_brightness = 0;
data->cdev.name = data->name;
--
1.5.6.5
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¤z¹ÞøÚ+h®ÏâØ^nr¡ö¦zË\x1aëh¨èÚ&£ûàz¿äz¹Þú+Ê+zf£¢·h§~Ûiÿÿïêÿêçz_è®\x0fæj:+v¨þ)ߣøm
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-04-13 0:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-10 12:40 [PATCH] fix checking in probe function Christoph Fritz
2010-04-13 0:50 ` Haojian Zhuang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox