[PATCH] Fix kfree usage in various mtd map remove functions (2nd go)

Phil Endecott spam_from_linux_mtd at chezphil.org
Sun May 27 08:49:42 EDT 2007


The remove() functions in various mtd map drivers were failing to free 
the *_flash_info
structure.

Since mtd drivers are rarely or never used as modules (they typically 
provide root filesystems)
it is unlikely that these code paths have ever been exercised.  It also 
means that this patch
has not been tested by the author.

This patch is against 2.6.21, and supersedes the version that I posted 
on 2007-05-17; that version made an additional incorrect change to the 
usage of release_resource().

Signed-off-by: Phil Endecott <spam_from_linux_mtd_patch <at> chezphil.org>

diff -Nur drivers/mtd/maps.orig/ixp2000.c drivers/mtd/maps/ixp2000.c
--- drivers/mtd/maps.orig/ixp2000.c	2007-05-17 18:56:10.000000000 +0100
+++ drivers/mtd/maps/ixp2000.c	2007-05-27 13:40:36.000000000 +0100
@@ -134,6 +134,8 @@
  		kfree(info->res);
  	}

+	kfree(info);
+
  	if (plat->exit)
  		plat->exit();

diff -Nur drivers/mtd/maps.orig/ixp4xx.c drivers/mtd/maps/ixp4xx.c
--- drivers/mtd/maps.orig/ixp4xx.c	2007-05-17 18:56:10.000000000 +0100
+++ drivers/mtd/maps/ixp4xx.c	2007-05-27 13:41:12.000000000 +0100
@@ -177,6 +177,8 @@
  		kfree(info->res);
  	}

+	kfree(info);
+
  	if (plat->exit)
  		plat->exit();

diff -Nur drivers/mtd/maps.orig/physmap.c drivers/mtd/maps/physmap.c
--- drivers/mtd/maps.orig/physmap.c	2007-05-17 18:56:10.000000000 +0100
+++ drivers/mtd/maps/physmap.c	2007-05-27 13:41:51.000000000 +0100
@@ -69,6 +69,8 @@
  		kfree(info->res);
  	}

+	kfree(info);
+
  	return 0;
  }

diff -Nur drivers/mtd/maps.orig/physmap_of.c drivers/mtd/maps/physmap_of.c
--- drivers/mtd/maps.orig/physmap_of.c	2007-05-17 18:56:10.000000000 +0100
+++ drivers/mtd/maps/physmap_of.c	2007-05-27 13:42:35.000000000 +0100
@@ -112,6 +112,8 @@
  		kfree(info->res);
  	}

+	kfree(info);
+
  	return 0;
  }









More information about the linux-mtd mailing list