All of lore.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Alberto Panizzo <maramaopercheseimorto@gmail.com>,
	";Richard Purdie" <rpurdie@linux.intel.com>
Subject: [PATCH] l4f00242t03: fix error handling in l4f00242t03_probe
Date: Mon, 03 May 2010 14:42:44 +0800	[thread overview]
Message-ID: <1272868964.2861.5.camel@mola> (raw)


This patch includes below fixes for properly error handling:
1. In the case of kzalloc failure, simple return -ENOMEM instead of goto
err. ( priv is NULL in this case )
2. In the case of gpio_request fail for reset_gpio and data_enable_gpio,
   properly release resources by goto err and err2 respectively.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/video/backlight/l4f00242t03.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/video/backlight/l4f00242t03.c
b/drivers/video/backlight/l4f00242t03.c
index bcdb12c..a4632db 100644
--- a/drivers/video/backlight/l4f00242t03.c
+++ b/drivers/video/backlight/l4f00242t03.c
@@ -125,8 +125,7 @@ static int __devinit l4f00242t03_probe(struct
spi_device *spi)
 
 	if (priv == NULL) {
 		dev_err(&spi->dev, "No memory for this device.\n");
-		ret = -ENOMEM;
-		goto err;
+		return -ENOMEM;
 	}
 
 	dev_set_drvdata(&spi->dev, priv);
@@ -139,7 +138,7 @@ static int __devinit l4f00242t03_probe(struct
spi_device *spi)
 	if (ret) {
 		dev_err(&spi->dev,
 			"Unable to get the lcd l4f00242t03 reset gpio.\n");
-		return ret;
+		goto err;
 	}
 
 	ret = gpio_direction_output(pdata->reset_gpio, 1);
@@ -151,7 +150,7 @@ static int __devinit l4f00242t03_probe(struct
spi_device *spi)
 	if (ret) {
 		dev_err(&spi->dev,
 			"Unable to get the lcd l4f00242t03 data en gpio.\n");
-		return ret;
+		goto err2;
 	}
 
 	ret = gpio_direction_output(pdata->data_enable_gpio, 0);
-- 
1.5.4.3




             reply	other threads:[~2010-05-03  6:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-03  6:42 Axel Lin [this message]
2010-05-03  8:06 ` [PATCH] l4f00242t03: fix error handling in l4f00242t03_probe Alberto Panizzo

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=1272868964.2861.5.camel@mola \
    --to=axel.lin@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maramaopercheseimorto@gmail.com \
    --cc=rpurdie@linux.intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.