diff mbox

[01/24] mtd/maps/pismo: remove dangling pointer and a leak

Message ID 20100320153146.GB5515@pengutronix.de
State Accepted
Commit 395b228858778d3c44f7c413693a6acaa8bb62dc
Headers show

Commit Message

Wolfram Sang March 20, 2010, 3:31 p.m. UTC
On Sat, Mar 20, 2010 at 02:57:30PM +0000, Russell King wrote:
> On Sat, Mar 20, 2010 at 03:12:42PM +0100, Wolfram Sang wrote:
> > + exit_free:
> > +	i2c_set_clientdata(client, NULL);
> > +	kfree(prismo);
> 
> And this is a compile error...

[grabbing some brown paper bags]

I'm sorry. That was one of the manually adapted ones :(
Here is the typo corrected:

Subject: [PATCH V2] mtd/maps/pismo: remove dangling pointer and a leak

While looking for drivers which forgot to clear i2c_clientdata before freeing
the data structure it points to, I found that the pismo driver even has a leak
on the probe error path.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: David Woodhouse <David.Woodhouse@intel.com>
---
 drivers/mtd/maps/pismo.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

Comments

Russell King March 20, 2010, 3:41 p.m. UTC | #1
On Sat, Mar 20, 2010 at 04:31:46PM +0100, Wolfram Sang wrote:
> Subject: [PATCH V2] mtd/maps/pismo: remove dangling pointer and a leak
> 
> While looking for drivers which forgot to clear i2c_clientdata before freeing
> the data structure it points to, I found that the pismo driver even has a leak
> on the probe error path.
> 
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> Cc: Russell King <rmk+kernel@arm.linux.org.uk>

Thanks.

Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>

David, are you going to pick this up?
David Woodhouse March 21, 2010, 8:30 a.m. UTC | #2
On Sat, 2010-03-20 at 15:41 +0000, Russell King wrote:
> 
> Thanks.
> 
> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
> 
> David, are you going to pick this up? 

http://git.infradead.org/mtd-2.6.git/commitdiff/395b2288

Thanks.
Wolfram Sang March 30, 2010, 12:26 p.m. UTC | #3
On Sun, Mar 21, 2010 at 08:30:41AM +0000, David Woodhouse wrote:

> > Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
> > 
> > David, are you going to pick this up? 
> 
> http://git.infradead.org/mtd-2.6.git/commitdiff/395b2288

Thanks. The handling of the dangling pointer will be handled differently from
2.6.35 on, but I will prepare the necessary fixup then. The fixed leak was
good to have, I think.
diff mbox

Patch

diff --git a/drivers/mtd/maps/pismo.c b/drivers/mtd/maps/pismo.c
index 30e12c8..f021018 100644
--- a/drivers/mtd/maps/pismo.c
+++ b/drivers/mtd/maps/pismo.c
@@ -233,6 +233,7 @@  static int __devexit pismo_remove(struct i2c_client *client)
 	/* FIXME: set_vpp needs saner arguments */
 	pismo_setvpp_remove_fix(pismo);
 
+	i2c_set_clientdata(client, NULL);
 	kfree(pismo);
 
 	return 0;
@@ -271,7 +272,7 @@  static int __devinit pismo_probe(struct i2c_client *client,
 	ret = pismo_eeprom_read(client, &eeprom, 0, sizeof(eeprom));
 	if (ret < 0) {
 		dev_err(&client->dev, "error reading EEPROM: %d\n", ret);
-		return ret;
+		goto exit_free;
 	}
 
 	dev_info(&client->dev, "%.15s board found\n", eeprom.board);
@@ -282,6 +283,11 @@  static int __devinit pismo_probe(struct i2c_client *client,
 				      pdata->cs_addrs[i]);
 
 	return 0;
+
+ exit_free:
+	i2c_set_clientdata(client, NULL);
+	kfree(pismo);
+	return ret;
 }
 
 static const struct i2c_device_id pismo_id[] = {