leak in mtd/devices/phram.c

Jörn Engel joern at lazybastard.org
Sun May 20 16:49:34 EDT 2007


On Sun, 20 May 2007 22:09:37 +0200, Eric Sesterhenn / Snakebyte wrote:
> 
> coverity spotted this leak in mtd/devices/phram.c (bug id #1512),
> when register_device() fails, we dont kfree() name and leak it,
> attached patch should fix this.
> 
> Signed-off-by: Eric Sesterhenn <snakebyte at gmx.de>

Acked-by: Jörn Engel <joern at lazybastard.org>

> --- linux-2.6/drivers/mtd/devices/phram.c.orig	2007-05-20 22:04:24.000000000 +0200
> +++ linux-2.6/drivers/mtd/devices/phram.c	2007-05-20 22:06:12.000000000 +0200
> @@ -276,7 +276,9 @@ static int phram_setup(const char *val, 
>  		parse_err("illegal device length\n");
>  	}
>  
> -	register_device(name, start, len);
> +	ret = register_device(name, start, len);
> +	if (ret)
> +		kfree(name);
>  
>  	return 0;
>  }
> 

Jörn

-- 
I can say that I spend most of my time fixing bugs even if I have lots
of new features to implement in mind, but I give bugs more priority.
-- Andrea Arcangeli, 2000
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.infradead.org/pipermail/linux-mtd/attachments/20070520/961c5b83/attachment.bin 


More information about the linux-mtd mailing list