From: "Hans J. Koch" <hjk@linutronix.de>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Greg KH <gregkh@suse.de>, LKML <linux-kernel@vger.kernel.org>,
Kay Sievers <kay.sievers@vrfy.org>
Subject: Re: [patch] drivers: Fix bogus 0 error return in device_add()
Date: Thu, 10 Dec 2009 22:55:14 +0100 [thread overview]
Message-ID: <20091210215514.GB2444@local> (raw)
In-Reply-To: <alpine.LFD.2.00.0912102158590.3089@localhost.localdomain>
On Thu, Dec 10, 2009 at 10:01:10PM +0100, Thomas Gleixner wrote:
> On Thu, 10 Dec 2009, Greg KH wrote:
> > On Thu, Dec 10, 2009 at 07:32:49PM -0000, Thomas Gleixner wrote:
> > > If device_add() is called with a device which does not have dev->p set
> > > up, then device_private_init() is called. If that succeeds, then the
> > > error variable is set to 0. Now if the dev_name(dev) check further
> > > down fails, then device_add() correctly terminates, but returns 0.
> > > That of course lets the driver progress. If later another driver uses
> > > this half set up device as parent then device_add() of the child
> > > device explodes and renders sysfs completely unusable.
> > >
> > > Set the error to -EINVAL if dev_name() check fails.
> >
> > That's a good catch, thanks.
> >
> > Is anything currently triggering this? Or did you just find it by
> > reading the code?
>
> Hans-Juergen had a buggy vendor driver where init_name was not
> initialized. So the driver probing succeeded and after that a
> depending driver crashed somewhere in device_add().
That was one of these USB UDC drivers. It falsely reported OK at probe time
and crashed when modprobing a gadget driver. Complete hang of the machine
could be achieved by just doing "ls /sys"...
Of course, it's the driver's fault not to set init_name, but it's a bit
annoying if such mistakes freeze your machine instead of simply producing
an error that helps fixing the driver.
Thanks,
Hans
prev parent reply other threads:[~2009-12-10 21:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-10 19:32 [patch] drivers: Fix bogus 0 error return in device_add() Thomas Gleixner
2009-12-10 20:56 ` Greg KH
2009-12-10 21:01 ` Thomas Gleixner
2009-12-10 21:49 ` Greg KH
2009-12-10 21:55 ` Hans J. Koch [this message]
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=20091210215514.GB2444@local \
--to=hjk@linutronix.de \
--cc=gregkh@suse.de \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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.