[PATCH] fix verify_dynamic_kobject_allocation()



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@xxxxxxxxxxxxxxxxxxx>

---

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) { }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • [PATCH] Regulator: lp3972 cleanup
    ... so I sent the fixes in one patch. ... if (ret < 0) ... -static int setup_regulators(struct lp3972 *lp3972, ...
    (Linux-Kernel)
  • Re: [PATCH] fix verify_dynamic_kobject_allocation()
    ... machine during boot when it calls kzalloc(), ... This patch fixes it by using a static ... string instead of a dynamically-allocated string. ... I just took andrew's version of this patch, ...
    (Linux-Kernel)
  • [PATCH 05/13] Fix free_layer()
    ... This patch only fixes the free_layerportion of ridr.c, ... return ret; ...
    (Linux-Kernel)
  • Re: .Net Directory Classes give COM errors
    ... Public Property DirEntryAs DirectoryEntry ... Private _DirSearch As DirectorySearcher ... Public Function MailAdressFromLDAP(ByVal sAMAccountName As String) As String ... Dim ret As String = String.Empty 'declare ret var ...
    (microsoft.public.dotnet.general)
  • YUI--Competent?
    ... @param attr The attribute to get. ... ret = el.getAttribute; ... they change it to an empty string per some imagined "DOM spec". ... unit testing and ostensibly have the best JS developers working around ...
    (comp.lang.javascript)