From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: ChengYi He <chengyihetaipei@gmail.com>,
Felipe Balbi <balbi@ti.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: ulpi: call put_device if device_register fails
Date: Wed, 22 Jul 2015 14:39:34 -0700 [thread overview]
Message-ID: <20150722213934.GA10425@kroah.com> (raw)
In-Reply-To: <20150623105738.GD1296@kuha.fi.intel.com>
On Tue, Jun 23, 2015 at 01:57:38PM +0300, Heikki Krogerus wrote:
> On Fri, Jun 19, 2015 at 01:12:36AM +0800, ChengYi He wrote:
> > put_device is required to release the last reference to the device.
> >
> > Signed-off-by: ChengYi He <chengyihetaipei@gmail.com>
> > ---
> > drivers/usb/common/ulpi.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
> > index 0e6f968..bd25bdb 100644
> > --- a/drivers/usb/common/ulpi.c
> > +++ b/drivers/usb/common/ulpi.c
> > @@ -184,8 +184,10 @@ static int ulpi_register(struct device *dev, struct ulpi *ulpi)
> > request_module("ulpi:v%04xp%04x", ulpi->id.vendor, ulpi->id.product);
> >
> > ret = device_register(&ulpi->dev);
> > - if (ret)
> > + if (ret) {
> > + put_device(&ulpi->dev);
>
> If device_register returns failure, put_device has already been
> called. Check device_add in drivers/base/core.c.
Yes, please read the function, which says:
* NOTE: _Never_ directly free @dev after calling this function, even
* if it returned an error! Always use put_device() to give up your
* reference instead.
But, the problem is that the ulpi core doesn't "own" that struct device.
It comes from elsewhere. It comes from somewhere deep down in the dw3
core, which is where I lost the path. Something needs to be fixed in
dwc3_probe() to properly clean up the device if it fails, which is not
happening right now.
So this patch would actually cause much bigger problems than fixing
anything, so it's wrong, but for a different reason than you are talking
about here.
And ugh, the ulpi and dwc code binding together, what a mess, horrid...
greg k-h
next prev parent reply other threads:[~2015-07-22 21:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-18 17:12 [PATCH] usb: ulpi: call put_device if device_register fails ChengYi He
2015-06-23 10:57 ` Heikki Krogerus
2015-07-22 21:39 ` Greg Kroah-Hartman [this message]
2015-07-23 2:04 ` Felipe Balbi
2015-07-23 3:14 ` Greg Kroah-Hartman
2015-07-23 5:02 ` Felipe Balbi
2015-07-23 18:00 ` Greg Kroah-Hartman
2015-07-23 20:08 ` Felipe Balbi
2015-07-23 20:46 ` Greg Kroah-Hartman
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=20150722213934.GA10425@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=balbi@ti.com \
--cc=chengyihetaipei@gmail.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox