mtd/maps/pismo: remove dangling pointer and a leak

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sun Mar 21 04:59:01 EDT 2010


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=395b228858778d3c44f7c413693a6acaa8bb62dc
Commit:     395b228858778d3c44f7c413693a6acaa8bb62dc
Parent:     4d682420cead1ce06d8cd44ae193414404f0e7f5
Author:     Wolfram Sang <w.sang at pengutronix.de>
AuthorDate: Sat Mar 20 15:31:46 2010 +0000
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Sun Mar 21 08:28:34 2010 +0000

    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 at pengutronix.de>
    Acked-by: Russell King <rmk+kernel at arm.linux.org.uk>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/maps/pismo.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/maps/pismo.c b/drivers/mtd/maps/pismo.c
index c48cad2..0a5e243 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[] = {



More information about the linux-mtd-cvs mailing list