sharp memory leak

Jörn Engel joern at wohnheim.fh-wedel.de
Thu Feb 13 03:59:27 EST 2003


On Wed, 12 February 2003 10:55:20 -0700, Thayne Harbaugh wrote:
> 
> I've been sitting on some patches for a while and have not sent them
> in.  I saw Jorn send in the patch for the missing cfi_cmdset_0020 and
> decided that I need to get my submissions in befor Jorn sends all of
> them in.

At least you allowed me to fix my own bug. I submitted cfi_cmdset_0020
a while ago and forgot the Makefile line. Darn!

> Here's just one - it's a memory leak in the sharp driver.  It's not huge
> and will likely never leak, but it needs to be there to balance the
> kmalloc().

Leak exists and fix is correct. It may also be worthwhile to do the
following instead:
	mtd = kmalloc
	if (!mtd)
		goto out1;
	sharp = kmalloc
	if (!sharp)
		goto out2;
	width = kmalloc
	if (!width)
		goto out3;
	...
	return mtd;
out3:
	kfree(width);
out2:
	kfree(sharp);
out1:
	kfree(mtd);
	return NULL;

Dunno, this is not a perfect candidate for that strategy, but it might
be slightly more obvious. You decide.

Jörn

-- 
With a PC, I always felt limited by the software available. On Unix, 
I am limited only by my knowledge.
-- Peter J. Schoenster




More information about the linux-mtd mailing list