public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Antonio Ospite <ospite@studenti.unina.it>,
	Wolfram Sang <w.sang@pengutronix.de>,
	Richard Purdie <rpurdie@linux.intel.com>
Subject: [PATCH v2] leds-lp3944: properly handle lp3944_configure fail in lp3944_probe
Date: Mon, 17 May 2010 17:47:48 +0800	[thread overview]
Message-ID: <1274089668.28623.3.camel@mola> (raw)

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 |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/leds-lp3944.c b/drivers/leds/leds-lp3944.c
index 8d5ecce..932a58d 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");
@@ -401,9 +402,13 @@ static int __devinit lp3944_probe(struct i2c_client *client,
 
 	mutex_init(&data->lock);
 
-	dev_info(&client->dev, "lp3944 enabled\n");
+	err = lp3944_configure(client, data, lp3944_pdata);
+	if (err < 0) {
+		kfree(data);
+		return err;
+	}
 
-	lp3944_configure(client, data, lp3944_pdata);
+	dev_info(&client->dev, "lp3944 enabled\n");
 	return 0;
 }
 
-- 
1.5.4.3




             reply	other threads:[~2010-05-17  9:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-17  9:47 Axel Lin [this message]
2010-05-17  9:53 ` [PATCH v2] leds-lp3944: properly handle lp3944_configure fail in lp3944_probe Wolfram Sang
2010-05-17 10:15 ` Antonio Ospite
2010-05-26 11:31   ` Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1274089668.28623.3.camel@mola \
    --to=axel.lin@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ospite@studenti.unina.it \
    --cc=rpurdie@linux.intel.com \
    --cc=w.sang@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox