lkml.org 
[lkml]   [2006]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] kobject: don't oops on null kobject.name
Greg KH <greg@kroah.com> wrote:
>
> >
> > I'd have thought that we'd want the test right at the start of
> > kobject_add() - fail it if ->name is zero. I don't know if that'd work for
> > all callers, but kobject_add() does play around with the ->name field and
> > will go oops if ->name==NULL and debugging is enabled.
>
> Something like this instead?

I think so.

> (warning, untested...)

Ship it!

> I'll try it out in a reboot cycle...
>
> --- gregkh-2.6.orig/lib/kobject.c 2006-01-13 09:15:18.000000000 -0800
> +++ gregkh-2.6/lib/kobject.c 2006-01-13 14:54:40.000000000 -0800
> @@ -164,6 +164,11 @@ int kobject_add(struct kobject * kobj)
> return -ENOENT;
> if (!kobj->k_name)
> kobj->k_name = kobj->name;
> + if (!kobj->k_name) {
> + pr_debug("kobject attempted to be registered with no name!\n");
> + WARN_ON(1);
> + return -EINVAL;
> + }
> parent = kobject_get(kobj->parent);
>
> pr_debug("kobject %s: registering. parent: %s, set: %s\n",

It might be worth emitting the warning and then proceeding rather than
failing - minimise potential disruption. I guess we'll see...
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-01-14 00:13    [W:0.050 / U:0.520 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site