lkml.org 
[lkml]   [2010]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] leds-lp3944: properly handle lp3944_configure fail in lp3944_probe
From
Date
In current implementation, lp3944_probe return 0 even if lp3944_configure fail.
Therefore, led_classdev_unregister will be executed twice ( in error handling of lp3944_configure and lp3944_remove ).
This patch properly handles lp3944_configure fail in lp3944_probe.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/leds/leds-lp3944.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/drivers/leds/leds-lp3944.c b/drivers/leds/leds-lp3944.c
index 8d5ecce..03a24d0 100644
--- a/drivers/leds/leds-lp3944.c
+++ b/drivers/leds/leds-lp3944.c
@@ -379,6 +379,7 @@ static int __devinit lp3944_probe(struct i2c_client *client,
{
struct lp3944_platform_data *lp3944_pdata = client->dev.platform_data;
struct lp3944_data *data;
+ int err;

if (lp3944_pdata == NULL) {
dev_err(&client->dev, "no platform data\n");
@@ -403,8 +404,15 @@ static int __devinit lp3944_probe(struct i2c_client *client,

dev_info(&client->dev, "lp3944 enabled\n");

- lp3944_configure(client, data, lp3944_pdata);
+ err = lp3944_configure(client, data, lp3944_pdata);
+ if (err < 0)
+ goto err_configure;
+
return 0;
+
+err_configure:
+ kfree(data);
+ return err;
}

static int __devexit lp3944_remove(struct i2c_client *client)
--
1.5.4.3




\
 
 \ /
  Last update: 2010-05-17 03:35    [from the cache]
©2003-2011 Jasper Spaans