From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755058AbbGWCEq (ORCPT ); Wed, 22 Jul 2015 22:04:46 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:40840 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753448AbbGWCEo (ORCPT ); Wed, 22 Jul 2015 22:04:44 -0400 Date: Wed, 22 Jul 2015 21:04:40 -0500 From: Felipe Balbi To: Greg Kroah-Hartman CC: Heikki Krogerus , ChengYi He , Felipe Balbi , , Subject: Re: [PATCH] usb: ulpi: call put_device if device_register fails Message-ID: <20150723020440.GB16806@saruman.tx.rr.com> Reply-To: References: <20150618171236.GA18007@chengyihe-ThinkCentre-M82> <20150623105738.GD1296@kuha.fi.intel.com> <20150722213934.GA10425@kroah.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="rJwd6BRFiFCcLxzm" Content-Disposition: inline In-Reply-To: <20150722213934.GA10425@kroah.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --rJwd6BRFiFCcLxzm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 22, 2015 at 02:39:34PM -0700, Greg Kroah-Hartman wrote: > 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. > > >=20 > > > Signed-off-by: ChengYi He > > > --- > > > drivers/usb/common/ulpi.c | 4 +++- > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > >=20 > > > 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, str= uct ulpi *ulpi) > > > request_module("ulpi:v%04xp%04x", ulpi->id.vendor, ulpi->id.product= ); > > > =20 > > > ret =3D device_register(&ulpi->dev); > > > - if (ret) > > > + if (ret) { > > > + put_device(&ulpi->dev); > >=20 > > If device_register returns failure, put_device has already been > > called. Check device_add in drivers/base/core.c. >=20 > 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. >=20 > 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. >=20 > 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. >=20 > And ugh, the ulpi and dwc code binding together, what a mess, horrid... any suggestions ? DWC *is* the one implementing the bus. If there's a better way, we can certainly shuffle code around. --=20 balbi --rJwd6BRFiFCcLxzm Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJVsEu4AAoJEIaOsuA1yqRENLYQAIGulJuKQ5mxOkTm1krl9GeQ 3BLPwtwEYyT7nl1NvO15ZaCfSeU/P64gsEUL2s280hpXr6Gx6M0g8f7fBUOV86gF 8Fnt0PQid9c01zubuQE1+gK6vGXlpbiRezy0Ewcz1w3MHmnBZZ/D+OHEMIchW+Xr 5wOmUBlMO739kNvDvz/nHZwPaEf7NzfQCfKygW9qkuOYyhpKSxi0Vpfrt5P84tIy bl76VTwSzDcyoJZz0NWwTws3yezTUdC3dkseV+6qwWrYnsk59v5l3IGhUI7w0/UQ 8AXwKTtcQnVSDeCf6SC5xMYSufQjxDjlyeQki9ldiFMcwKSu9Fab4yHtpBx1DNFl PGH/zqVik9Kq7jqWU/WuGVjXHRf0iWaGB262BXA/KdQ4dH5o0xAUNMKWyj+aOk+D Ri7hwTuAz+rFsW/NK6ABY1aDK8D6x25lpL5u8R3Rb3AW7G0GG6CWrXP1pYVHyAeD RhcBC7MpI97k2M19qQw1JemkNaKMvgS9utH+ZPhfRr9ptoTQGgsZxTPYXpoIWRhL PwCqVveVLqXm1ji+/3FU4doZQnb4rwNUxOveObuDWYjDJnS6cEyQUTX3v7zp4WQp oxqAA4yLbmUM/gyoiRBnVsagnM8OmTNxDNOSanqMoGPUX3dG48rafAU+ZfUiSkY+ cLBMVBDz9XmOhpMIft9g =lEut -----END PGP SIGNATURE----- --rJwd6BRFiFCcLxzm--