mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Graeme Gregory <gg@slimlogic.co.uk>
To: linux-kernel@vger.kernel.org
Cc: broonie@opensource.wolfsonmicro.com, lrg@ti.com,
	sameo@linux.intel.com, peter.ujfalusi@ti.com, s-guiriec@ti.com,
	Graeme Gregory <gg@slimlogic.co.uk>
Subject: [PATCH 1/6] mfd: palmas improve the error exit path
Date: Tue, 28 Aug 2012 13:47:35 +0200	[thread overview]
Message-ID: <1346154460-20031-2-git-send-email-gg@slimlogic.co.uk> (raw)
In-Reply-To: <1346154460-20031-1-git-send-email-gg@slimlogic.co.uk>

Improve the error exit path so that we correctly de-allocate resources
that have been allocated upto the point where error occurs.

Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
---
 drivers/mfd/palmas.c |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index c4a69f1..5ffd330 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -377,11 +377,11 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
 		reg = pdata->pad1;
 		ret = regmap_write(palmas->regmap[slave], addr, reg);
 		if (ret)
-			goto err;
+			goto err_irq;
 	} else {
 		ret = regmap_read(palmas->regmap[slave], addr, &reg);
 		if (ret)
-			goto err;
+			goto err_irq;
 	}
 
 	if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_0))
@@ -412,11 +412,11 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
 		reg = pdata->pad2;
 		ret = regmap_write(palmas->regmap[slave], addr, reg);
 		if (ret)
-			goto err;
+			goto err_irq;
 	} else {
 		ret = regmap_read(palmas->regmap[slave], addr, &reg);
 		if (ret)
-			goto err;
+			goto err_irq;
 	}
 
 	if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD2_GPIO_4))
@@ -439,13 +439,13 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
 
 	ret = regmap_write(palmas->regmap[slave], addr, reg);
 	if (ret)
-		goto err;
+		goto err_irq;
 
 	children = kmemdup(palmas_children, sizeof(palmas_children),
 			   GFP_KERNEL);
 	if (!children) {
 		ret = -ENOMEM;
-		goto err;
+		goto err_irq;
 	}
 
 	children[PALMAS_PMIC_ID].platform_data = pdata->pmic_pdata;
@@ -457,13 +457,15 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c,
 	kfree(children);
 
 	if (ret < 0)
-		goto err;
+		goto err_devices;
 
 	return ret;
 
-err:
+err_devices:
 	mfd_remove_devices(palmas->dev);
-	kfree(palmas);
+err_irq:
+	regmap_del_irq_chip(palmas->irq, palmas->irq_data);
+err:
 	return ret;
 }
 
-- 
1.7.9.5


  reply	other threads:[~2012-08-28 11:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-28 11:47 [PATCH 0/6] some small cleanups for palmas and DT support Graeme Gregory
2012-08-28 11:47 ` Graeme Gregory [this message]
2012-08-28 11:47 ` [PATCH 2/6] mfd: palmas switch to linear domain in all cases Graeme Gregory
2012-08-28 18:11   ` Mark Brown
2012-08-28 20:10     ` Graeme Gregory
2012-08-28 20:10       ` Mark Brown
2012-08-28 11:47 ` [PATCH 3/6] mfd: palmas add pdata/data for rest of children Graeme Gregory
2012-08-28 11:47 ` [PATCH 4/6] mfd: palmas add device tree handling to mfd Graeme Gregory
2012-08-28 16:49   ` Mark Brown
2012-08-28 11:47 ` [PATCH 5/6] mfd: change regulator defns to better suite DT Graeme Gregory
2012-08-28 11:47 ` [PATCH 6/6] regulator: palmas add DT support Graeme Gregory
2012-09-19 15:30 ` [PATCH 0/6] some small cleanups for palmas and " Samuel Ortiz
2012-09-19 16:05   ` Graeme Gregory

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=1346154460-20031-2-git-send-email-gg@slimlogic.co.uk \
    --to=gg@slimlogic.co.uk \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=peter.ujfalusi@ti.com \
    --cc=s-guiriec@ti.com \
    --cc=sameo@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®