All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Andrew Morton <akpm@osdl.org>
Cc: 76306.1226@compuserve.com, linux-kernel@vger.kernel.org
Subject: Re: [patch] kobject: don't oops on null kobject.name
Date: Fri, 13 Jan 2006 16:02:46 -0800	[thread overview]
Message-ID: <20060114000246.GA7549@kroah.com> (raw)
In-Reply-To: <20060113151213.61e40f2b.akpm@osdl.org>

On Fri, Jan 13, 2006 at 03:12:13PM -0800, Andrew Morton wrote:
> 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!

Heh, it works for me, I'm running with it right now :)

> 
> > 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...

Hm, I looked at the only user of kobjects in the kernel that I know of
that doesn't use sysfs (the cdev code) and even it sets the kobject name
to something sane, so I think we should be safe with this.

I'll add it to my tree and let's see what the next -mm causes to pop up
:)

thanks,

greg k-h

  reply	other threads:[~2006-01-14  0:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-13  1:02 [patch] kobject: don't oops on null kobject.name Chuck Ebbert
2006-01-13 22:30 ` Andrew Morton
2006-01-13 22:55   ` Greg KH
2006-01-13 23:12     ` Andrew Morton
2006-01-14  0:02       ` Greg KH [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-01-14  3:07 Chuck Ebbert
2006-01-14  3:07 Chuck Ebbert
2006-01-14  3:44 ` Greg KH
2006-01-14 16:18 Chuck Ebbert
2006-02-06 20:29 [PATCH] SPI: spi_butterfly, restore lost deltas Greg KH
2006-02-06 20:29 ` [PATCH] kobject: don't oops on null kobject.name Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060114000246.GA7549@kroah.com \
    --to=greg@kroah.com \
    --cc=76306.1226@compuserve.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.