[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080610155848.GS26334@ajones-laptop.nbttech.com>
Date: Tue, 10 Jun 2008 08:58:50 -0700
From: Arthur Jones <ajones@...erbed.com>
To: Greg KH <greg@...ah.com>
CC: linux-kernel@...r.kernel.org, Doug Thompson <norsk5@...oo.com>,
bluesmoke-devel@...ts.sourceforge.net
Subject: on static kobjects and double frees...
Hi Greg, The edac pci sysfs generic layer uses a static
kobject as a placeholder parent where edac pci drivers
are inserted. An atomic count is used to know when
to kobject_init_add_add or kobject_put the static kobject.
The issue with this is that the name gets double freed
on the second module load as edac does not clear it, and
kobject_cleanup does not clear it.
The quick fix was to clear the static kobj name before
calling kobject_init, but that seems a bit fragile as it
involves knowing the internals of kobject_put. Perhaps
the name should be cleared before calling the kobject
release method? Something like this (not even compile
tested):
diff --git a/lib/kobject.c b/lib/kobject.c
index 718e510..7dfe906 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -552,6 +552,9 @@ static void kobject_cleanup(struct kobject *kobj)
if (t && t->release) {
pr_debug("kobject: '%s' (%p): calling ktype release\n",
kobject_name(kobj), kobj);
+
+ /* avoid double free with static kobjects... */
+ kobj->name = NULL;
t->release(kobj);
}
What do you think? I'm happy to implement and test whatever
you think is best...
The edac code in question is drivers/edac/edac_pci_sysfs.c,
the static kobject is called edac_pci_top_main_kobj...
Arthur
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists