* [PATCH 01/24] mtd/maps/pismo: remove dangling pointer and a leak [not found] <1269094385-16114-1-git-send-email-w.sang@pengutronix.de> @ 2010-03-20 14:12 ` Wolfram Sang 2010-03-20 14:57 ` Russell King 0 siblings, 1 reply; 6+ messages in thread From: Wolfram Sang @ 2010-03-20 14:12 UTC (permalink / raw) To: kernel-janitors Cc: David Woodhouse, Wolfram Sang, linux-kernel, linux-mtd, linux-i2c, Russell King 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(-) diff --git a/drivers/mtd/maps/pismo.c b/drivers/mtd/maps/pismo.c index 30e12c8..86081bc 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(prismo); + return ret; } static const struct i2c_device_id pismo_id[] = { -- 1.7.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 01/24] mtd/maps/pismo: remove dangling pointer and a leak 2010-03-20 14:12 ` [PATCH 01/24] mtd/maps/pismo: remove dangling pointer and a leak Wolfram Sang @ 2010-03-20 14:57 ` Russell King 2010-03-20 15:31 ` Wolfram Sang 0 siblings, 1 reply; 6+ messages in thread From: Russell King @ 2010-03-20 14:57 UTC (permalink / raw) To: Wolfram Sang Cc: David Woodhouse, linux-mtd, kernel-janitors, linux-i2c, linux-kernel 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... -- Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 01/24] mtd/maps/pismo: remove dangling pointer and a leak 2010-03-20 14:57 ` Russell King @ 2010-03-20 15:31 ` Wolfram Sang 2010-03-20 15:41 ` Russell King 0 siblings, 1 reply; 6+ messages in thread From: Wolfram Sang @ 2010-03-20 15:31 UTC (permalink / raw) To: Russell King Cc: kernel-janitors, linux-mtd, David Woodhouse, linux-kernel, linux-i2c [-- Attachment #1: Type: text/plain, Size: 2049 bytes --] 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(-) 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[] = { -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 01/24] mtd/maps/pismo: remove dangling pointer and a leak 2010-03-20 15:31 ` Wolfram Sang @ 2010-03-20 15:41 ` Russell King 2010-03-21 8:30 ` David Woodhouse 0 siblings, 1 reply; 6+ messages in thread From: Russell King @ 2010-03-20 15:41 UTC (permalink / raw) To: Wolfram Sang Cc: kernel-janitors, linux-mtd, David Woodhouse, linux-kernel, linux-i2c 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? -- Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 01/24] mtd/maps/pismo: remove dangling pointer and a leak 2010-03-20 15:41 ` Russell King @ 2010-03-21 8:30 ` David Woodhouse 2010-03-30 12:26 ` Wolfram Sang 0 siblings, 1 reply; 6+ messages in thread From: David Woodhouse @ 2010-03-21 8:30 UTC (permalink / raw) To: Russell King Cc: kernel-janitors@vger.kernel.org, linux-mtd@lists.infradead.org, Wolfram Sang, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org 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. -- David Woodhouse Open Source Technology Centre David.Woodhouse@intel.com Intel Corporation ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 01/24] mtd/maps/pismo: remove dangling pointer and a leak 2010-03-21 8:30 ` David Woodhouse @ 2010-03-30 12:26 ` Wolfram Sang 0 siblings, 0 replies; 6+ messages in thread From: Wolfram Sang @ 2010-03-30 12:26 UTC (permalink / raw) To: David Woodhouse Cc: linux-mtd@lists.infradead.org, Russell King, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 580 bytes --] 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. -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-03-30 12:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1269094385-16114-1-git-send-email-w.sang@pengutronix.de>
2010-03-20 14:12 ` [PATCH 01/24] mtd/maps/pismo: remove dangling pointer and a leak Wolfram Sang
2010-03-20 14:57 ` Russell King
2010-03-20 15:31 ` Wolfram Sang
2010-03-20 15:41 ` Russell King
2010-03-21 8:30 ` David Woodhouse
2010-03-30 12:26 ` Wolfram Sang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox