[PATCH] Use after free in mtd/phram.c: unregister_devices()

Alexander Nyberg alexn at dsv.su.se
Wed Feb 23 03:43:25 EST 2005


Use after free, found by the Coverity tool

Signed-off-by: Alexander Nyberg <alexn at dsv.su.se>

===== drivers/mtd/devices/phram.c 1.6 vs edited =====
--- 1.6/drivers/mtd/devices/phram.c	2005-01-05 19:08:36 +01:00
+++ edited/drivers/mtd/devices/phram.c	2005-02-23 09:29:59 +01:00
@@ -107,9 +107,9 @@ static int phram_write(struct mtd_info *
 
 static void unregister_devices(void)
 {
-	struct phram_mtd_list *this;
+	struct phram_mtd_list *this, *safe;
 
-	list_for_each_entry(this, &phram_list, list) {
+	list_for_each_entry_safe(this, safe, &phram_list, list) {
 		del_mtd_device(&this->mtd);
 		iounmap(this->mtd.priv);
 		kfree(this);






More information about the linux-mtd mailing list