From: "Phil Endecott" <spam_from_linux_mtd@chezphil.org>
To: <linux-mtd@lists.infradead.org>
Subject: [PATCH] Fix kfree usage in various mtd map remove functions
Date: Thu, 17 May 2007 19:18:14 +0100 [thread overview]
Message-ID: <1179425894742@dmwebmail.belize.chezphil.org> (raw)
The remove() functions in various mtd map drivers were incorrectly kfree()ing the struct
resource that they had passed to release_resource(), and/or failing to free the *_flash_info
structure. This looks like a typo which has gradually propogated by copy&paste into a number
of these drivers.
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.
Signed-off-by: Phil Endecott <spam_from_linux_mtd_patch@chezphil.org>
diff -Nur linux-arm-2.6.21/drivers/mtd/maps.orig/integrator-flash.c linux-arm-2.6.21/drivers/mtd/maps/integrator-flash.c
--- linux-arm-2.6.21/drivers/mtd/maps.orig/integrator-flash.c 2007-05-17 18:56:10.000000000 +0100
+++ linux-arm-2.6.21/drivers/mtd/maps/integrator-flash.c 2007-05-17 18:58:16.000000000 +0100
@@ -174,7 +174,6 @@
iounmap(info->map.virt);
release_resource(info->res);
- kfree(info->res);
if (info->plat && info->plat->exit)
info->plat->exit();
diff -Nur linux-arm-2.6.21/drivers/mtd/maps.orig/ixp2000.c linux-arm-2.6.21/drivers/mtd/maps/ixp2000.c
--- linux-arm-2.6.21/drivers/mtd/maps.orig/ixp2000.c 2007-05-17 18:56:10.000000000 +0100
+++ linux-arm-2.6.21/drivers/mtd/maps/ixp2000.c 2007-05-17 18:57:29.000000000 +0100
@@ -129,10 +129,10 @@
kfree(info->partitions);
- if (info->res) {
+ if (info->res)
release_resource(info->res);
- kfree(info->res);
- }
+
+ kfree(info);
if (plat->exit)
plat->exit();
diff -Nur linux-arm-2.6.21/drivers/mtd/maps.orig/ixp4xx.c linux-arm-2.6.21/drivers/mtd/maps/ixp4xx.c
--- linux-arm-2.6.21/drivers/mtd/maps.orig/ixp4xx.c 2007-05-17 18:56:10.000000000 +0100
+++ linux-arm-2.6.21/drivers/mtd/maps/ixp4xx.c 2007-05-17 18:57:02.000000000 +0100
@@ -172,10 +172,10 @@
kfree(info->partitions);
- if (info->res) {
+ if (info->res)
release_resource(info->res);
- kfree(info->res);
- }
+
+ kfree(info);
if (plat->exit)
plat->exit();
Binary files linux-arm-2.6.21/drivers/mtd/maps.orig/ixp4xx.o and linux-arm-2.6.21/drivers/mtd/maps/ixp4xx.o differ
diff -Nur linux-arm-2.6.21/drivers/mtd/maps.orig/physmap.c linux-arm-2.6.21/drivers/mtd/maps/physmap.c
--- linux-arm-2.6.21/drivers/mtd/maps.orig/physmap.c 2007-05-17 18:56:10.000000000 +0100
+++ linux-arm-2.6.21/drivers/mtd/maps/physmap.c 2007-05-17 18:59:20.000000000 +0100
@@ -64,10 +64,10 @@
if (info->map.virt != NULL)
iounmap(info->map.virt);
- if (info->res != NULL) {
+ if (info->res)
release_resource(info->res);
- kfree(info->res);
- }
+
+ kfree(info);
return 0;
}
diff -Nur linux-arm-2.6.21/drivers/mtd/maps.orig/physmap_of.c linux-arm-2.6.21/drivers/mtd/maps/physmap_of.c
--- linux-arm-2.6.21/drivers/mtd/maps.orig/physmap_of.c 2007-05-17 18:56:10.000000000 +0100
+++ linux-arm-2.6.21/drivers/mtd/maps/physmap_of.c 2007-05-17 18:59:57.000000000 +0100
@@ -107,10 +107,10 @@
if (info->map.virt != NULL)
iounmap(info->map.virt);
- if (info->res != NULL) {
+ if (info->res)
release_resource(info->res);
- kfree(info->res);
- }
+
+ kfree(info);
return 0;
}
next reply other threads:[~2007-05-17 18:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-17 18:18 Phil Endecott [this message]
2007-05-21 15:44 ` [PATCH] Fix kfree usage in various mtd map remove functions MikeW
2007-05-21 17:09 ` Phil Endecott
2007-05-23 8:01 ` MikeW
2007-05-21 15:53 ` MikeW
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1179425894742@dmwebmail.belize.chezphil.org \
--to=spam_from_linux_mtd@chezphil.org \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox