From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Sasha Levin <sasha.levin@oracle.com>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>,
Greg KH <gregkh@linuxfoundation.org>,
Alan Stern <stern@rowland.harvard.edu>,
Tal Shorer <tal.shorer@gmail.com>,
USB list <linux-usb@vger.kernel.org>,
"<linux-kernel@vger.kernel.org>" <linux-kernel@vger.kernel.org>,
David Cohen <david.a.cohen@linux.intel.com>,
Felipe Balbi <balbi@ti.com>, Lu Baolu <baolu.lu@linux.intel.com>
Subject: Re: [PATCH] usb: ulpi: don't register drivers if bus doesn't exist
Date: Thu, 28 May 2015 16:24:58 +0300 [thread overview]
Message-ID: <20150528132458.GA12315@kuha.fi.intel.com> (raw)
In-Reply-To: <55670BDE.5070103@oracle.com>
On Thu, May 28, 2015 at 08:36:46AM -0400, Sasha Levin wrote:
> On 05/28/2015 01:39 AM, Sudip Mukherjee wrote:
> > diff --git a/drivers/base/driver.c b/drivers/base/driver.c
> > index 4eabfe2..1acae5b 100644
> > --- a/drivers/base/driver.c
> > +++ b/drivers/base/driver.c
> > @@ -150,6 +150,11 @@ int driver_register(struct device_driver *drv)
> > int ret;
> > struct device_driver *other;
> >
> > + if (!drv->bus->registered) {
> > + pr_err("Driver %s registration failed. bus not yet registered\n",
> > + drv->name);
> > + return -ENODEV;
> > + }
> > BUG_ON(!drv->bus->p);
>
> This is a design issue with the code in the layer above, there's no reason
> driver_register() should be called with a bus that wasn't registered to
> begin with.
>
> This is why there's a BUG_ON there to catch these issues - it's a bug, not
> a desired behaviour.
Unfortunately problems with the design are not the only cases why we
could end up here before the bus has been registered. If the bus has
failed to register, we definitely should not trigger a BUG here. The
bus management driver has in that case already made the decision to
not BUG. Or if the user is allowed to disable a bus somehow, for
example with something like nousb parameter, but we still manage do
get here, we should again not trigger BUG().
I don't think BUG_ON here is ever the correct thing to do. This
function can see that the bus doesn't exist or possibly that something
has gone wrong by checking the "p", but it does not know any details,
nor should it. This function should trigger a warning in those cases
and return failure, and not make any extra decisions.
Thanks,
--
heikki
next prev parent reply other threads:[~2015-05-28 13:25 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-20 19:33 [PATCH] usb: ulpi: don't register drivers if bus doesn't exist Sasha Levin
2015-05-20 21:22 ` David Cohen
2015-05-21 6:39 ` Lu, Baolu
2015-05-21 7:21 ` Heikki Krogerus
2015-05-22 10:16 ` Heikki Krogerus
2015-05-22 10:52 ` Heikki Krogerus
2015-05-22 14:21 ` Sasha Levin
2015-05-24 7:19 ` Greg KH
2015-05-24 8:09 ` Sudip Mukherjee
2015-05-24 14:30 ` Tal Shorer
2015-05-25 11:40 ` Heikki Krogerus
2015-05-25 16:13 ` Greg KH
2015-05-25 17:00 ` Bjørn Mork
2015-05-26 17:54 ` David Cohen
2015-05-27 2:41 ` Greg KH
2015-05-27 4:35 ` Sudip Mukherjee
2015-05-27 16:49 ` David Cohen
2015-05-27 2:39 ` Greg KH
2015-05-27 8:39 ` Heikki Krogerus
2015-05-27 9:05 ` Sudip Mukherjee
2015-05-27 15:16 ` Alan Stern
2015-05-27 15:21 ` Greg KH
2015-05-28 5:39 ` Sudip Mukherjee
2015-05-28 5:54 ` Felipe Balbi
2015-05-28 6:42 ` Sudip Mukherjee
2015-05-28 6:53 ` Sudip Mukherjee
2015-05-28 15:57 ` Alan Stern
2015-05-28 12:36 ` Sasha Levin
2015-05-28 13:24 ` Heikki Krogerus [this message]
2015-05-28 16:23 ` 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=20150528132458.GA12315@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=balbi@ti.com \
--cc=baolu.lu@linux.intel.com \
--cc=david.a.cohen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sasha.levin@oracle.com \
--cc=stern@rowland.harvard.edu \
--cc=sudipm.mukherjee@gmail.com \
--cc=tal.shorer@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox