From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751518AbdAPLVe (ORCPT ); Mon, 16 Jan 2017 06:21:34 -0500 Received: from mga05.intel.com ([192.55.52.43]:34660 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751150AbdAPLVb (ORCPT ); Mon, 16 Jan 2017 06:21:31 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,238,1477983600"; d="asc'?scan'208";a="1083543708" From: Felipe Balbi To: Alexandre Belloni Cc: David Laight , Nicolas Ferre , "linux-arm-kernel\@lists.infradead.org" , "linux-kernel\@vger.kernel.org" , "linux-usb\@vger.kernel.org" Subject: Re: [PATCH] usb: gadget: udc: atmel: used managed kasprintf In-Reply-To: <20170116111128.ft2b5aa63y2qe35p@piout.net> References: <20161201102656.29041-1-alexandre.belloni@free-electrons.com> <063D6719AE5E284EB5DD2968C1650D6DB0232C0D@AcuExch.aculab.com> <20161202161921.ace5rolitlxjhr6i@piout.net> <063D6719AE5E284EB5DD2968C1650D6DB023508B@AcuExch.aculab.com> <87eg03nvuv.fsf@linux.intel.com> <20170116111128.ft2b5aa63y2qe35p@piout.net> Date: Mon, 16 Jan 2017 13:19:25 +0200 Message-ID: <87bmv7mev6.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Alexandre Belloni writes: >> David Laight writes: >> > From: Alexandre Belloni >> >> Sent: 02 December 2016 16:19 >> >> On 02/12/2016 at 15:59:57 +0000, David Laight wrote : >> >> > From: Alexandre Belloni >> >> > > Sent: 01 December 2016 10:27 >> >> > > Use devm_kasprintf instead of simple kasprintf to free the alloca= ted memory >> >> > > when needed. >> >> > >> >> > s/when needed/when the device is freed/ >> >> > >> >> > > Suggested-by: Peter Rosin >> >> > > Signed-off-by: Alexandre Belloni >> >> > > --- >> >> > > drivers/usb/gadget/udc/atmel_usba_udc.c | 3 ++- >> >> > > 1 file changed, 2 insertions(+), 1 deletion(-) >> >> > > >> >> > > diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/us= b/gadget/udc/atmel_usba_udc.c >> >> > > index 45bc997d0711..aec72fe8273c 100644 >> >> > > --- a/drivers/usb/gadget/udc/atmel_usba_udc.c >> >> > > +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c >> >> > > @@ -1978,7 +1978,8 @@ static struct usba_ep * atmel_udc_of_init(s= truct platform_device *pdev, >> >> > > dev_err(&pdev->dev, "of_probe: name error(%d)\n", ret); >> >> > > goto err; >> >> > > } >> >> > > - ep->ep.name =3D kasprintf(GFP_KERNEL, "ep%d", ep->index); >> >> > > + ep->ep.name =3D devm_kasprintf(&pdev->dev, GFP_KERNEL, "ep%d", >> >> > > + ep->index); >> >> > >> >> > Acually why bother mallocing such a small string at all. >> >> > The maximum length is 12 bytes even if 'index' are unrestricted. >> >> > >> >>=20 >> >> IIRC, using statically allocated string is failing somewhere is the U= SB >> >> core but I don't remember all the details. >> > >> > I can't imagine that changing ep->ep.name from 'char *' to 'char [12]'= would >> > make any difference. >>=20 >> the actual name is managed by the UDC. Meaning, ep->ep.name should be a >> pointer, but it could very well just point to ep->name which would be >> char [12]. >>=20 > > Yeah, I sent a patch that did just that. > http://lists.infradead.org/pipermail/linux-arm-kernel/2017-January/478602= .html it's in my fixes now :-) =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEElLzh7wn96CXwjh2IzL64meEamQYFAlh8rD0ACgkQzL64meEa mQYTaBAAz2WiE+wfguPxgUQI3uMgSry4wwJ70cZjaX8dPgVFyMRsfnZ/nwUP64JC 6VM846O4u7UKdgZ2PTwIBbB2YxhfNCcuZ8Qdzu7nDzI+fKXSRbWuWrDvJXqer2Qv 2ag7IJyt93ACtEwOxmF8329s29K42iUFgNQZsxPjn++jnaxSDinfoLOv7EmUpLGZ dSyE1ilTZoin3mNKRiXHYqknvsQ6Ae8aWa6kB231BBpmwmcSC0c0KY2/zHziXXl6 s+4hE39T6a5iJXqLRVQ8Efd7mSzPAabYhW5kMghikueINE+3mUxtSLiuRgKjqGJI rsXeMnK4ZffDrmz4Jd5jc8SeYgy2hqtcUkEEYJrW8oM01HhtDLzPD1Btnwm6m+Tp xYGH3ftRvhBJ5z+jE/SWOHuGAy3LmfskXJfYCN8Hbuf8SM26Gh0wRYntmiYCldSa bIsqsK9Cf1rbimbjB2d2xnyraS8fYFo4gTjKZk56AgQF322FsLYROxSDymTSziLJ j+FaQsws4j2rPa7cL8RpBBnoVSLmQh5YHYH8d4Wy4vnVr7js7CG32BEhQnwvxXJl kgr9PwrOPVr5kofri1gqbd95ZJWlynXkUGBD39ze/hSpJhnwrw2allxJJFWEk/Dx Wpf4WVPwf3xcrm6ehDrQFPzSZhuTtfHnznLuoyTzI3pHZQUW8vw= =kmUQ -----END PGP SIGNATURE----- --=-=-=--