leak in mtd/devices/phram.c

Eric Sesterhenn / Snakebyte snakebyte at gmx.de
Sun May 20 16:09:37 EDT 2007


hi,

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>


--- 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;
 }




More information about the linux-mtd mailing list