All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix verify_dynamic_kobject_allocation()
@ 2008-08-06 20:00 Alan Stern
  2008-08-06 23:52 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Stern @ 2008-08-06 20:00 UTC (permalink / raw)
  To: Greg KH, Dave Hansen; +Cc: Kernel development list

The warn-when-statically-allocated-kobjects-are-used patch crashes my
machine during boot when it calls kzalloc(), presumably because the
call occurs too early.  This patch (as1126) fixes it by using a static
string instead of a dynamically-allocated string.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

---

Index: usb-2.6/lib/kobject.c
===================================================================
--- usb-2.6.orig/lib/kobject.c
+++ usb-2.6/lib/kobject.c
@@ -38,10 +38,9 @@ static int ptr_in_range(void *ptr, void 
 
 static void verify_dynamic_kobject_allocation(struct kobject *kobj)
 {
-	char *namebuf;
+	static char namebuf[KSYM_NAME_LEN];
 	const char *ret;
 
-	namebuf = kzalloc(KSYM_NAME_LEN, GFP_KERNEL);
 	ret = kallsyms_lookup((unsigned long)kobj, NULL, NULL, NULL,
 			namebuf);
 	/*
@@ -52,9 +51,9 @@ static void verify_dynamic_kobject_alloc
 	 */
 	if (!initmem_now_dynamic &&
 	    ptr_in_range(kobj, __init_begin, __init_end))
-		goto out;
+		return;
 	if (!ret || !strlen(ret))
-		goto out;
+		return;
 	pr_debug("---- begin silly warning ----\n");
 	pr_debug("This is a janitorial warning, not a kernel bug.\n");
 	pr_debug("The kobject '%s', at, or inside '%s'@(0x%p) is not "
@@ -62,8 +61,6 @@ static void verify_dynamic_kobject_alloc
 	pr_debug("kobjects must be dynamically allocated, not static\n");
 	/* dump_stack(); */
 	pr_debug("---- end silly warning ----\n");
-out:
-	kfree(namebuf);
 }
 #else
 static void verify_dynamic_kobject_allocation(struct kobject *kobj) { }


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-07  0:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-06 20:00 [PATCH] fix verify_dynamic_kobject_allocation() Alan Stern
2008-08-06 23:52 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.