diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2008-10-20 12:54:20 +1100 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2008-10-20 12:54:20 +1100 |
commit | d96a560ce58319c40ee0b4a04079d0244337e65e (patch) | |
tree | 9ffad5b9f8446ea66f7ed84e69297fb65f82b6f3 /lib | |
parent | 8af207c41bbdd099eb650760d905ccb583c9042d (diff) | |
parent | 0f8bf1f2e0b12a72ae3fbd580bc606b60f9d4238 (diff) |
Merge branch 'quilt/driver-core'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kobject.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index 0487d1f64806..2fded6d8ca54 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -17,6 +17,55 @@ #include <linux/module.h> #include <linux/stat.h> #include <linux/slab.h> +#include <linux/kallsyms.h> +#include <asm-generic/sections.h> + +#ifdef CONFIG_X86_32 +static int ptr_in_range(void *ptr, void *start, void *end) +{ + /* + * This should hopefully get rid of causing warnings + * if the architecture did not set one of the section + * variables up. + */ + if (start >= end) + return 0; + + if ((ptr >= start) && (ptr < end)) + return 1; + return 0; +} + +static void verify_dynamic_kobject_allocation(struct kobject *kobj) +{ + char namebuf[KSYM_NAME_LEN]; + const char *ret; + + ret = kallsyms_lookup((unsigned long)kobj, NULL, NULL, NULL, namebuf); + /* + * This is the X86_32-only part of this function. + * This is here because it is valid to have a kobject + * in an __init section, but only after those + * sections have been freed back to the dynamic pool. + */ + if (!initmem_now_dynamic && + ptr_in_range(kobj, __init_begin, __init_end)) + goto out; + if (!ret || !strlen(ret)) + goto out; + 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 " + "dynamically allocated.\n", kobject_name(kobj), namebuf, kobj); + pr_debug("kobjects must be dynamically allocated, not static\n"); + /* dump_stack(); */ + pr_debug("---- end silly warning ----\n"); +out: + return; +} +#else +static void verify_dynamic_kobject_allocation(struct kobject *kobj) { } +#endif /* * populate_dir - populate directory with attributes. @@ -282,6 +331,7 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype) "object, something is seriously wrong.\n", kobj); dump_stack(); } + verify_dynamic_kobject_allocation(kobj); kobject_init_internal(kobj); kobj->ktype = ktype; |