Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752186AbcLERRO convert rfc822-to-8bit (ORCPT ); Mon, 5 Dec 2016 12:17:14 -0500 Received: from smtp-out6.electric.net ([192.162.217.195]:62112 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751503AbcLERRL (ORCPT ); Mon, 5 Dec 2016 12:17:11 -0500 From: David Laight To: "'Alexandre Belloni'" CC: Felipe Balbi , 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 Thread-Topic: [PATCH] usb: gadget: udc: atmel: used managed kasprintf Thread-Index: AQHSS719Ez3IdtLGr0i16W1I0l5hdKD00gXggAAGLYCABMZ9kA== Date: Mon, 5 Dec 2016 17:17:03 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6DB023508B@AcuExch.aculab.com> References: <20161201102656.29041-1-alexandre.belloni@free-electrons.com> <063D6719AE5E284EB5DD2968C1650D6DB0232C0D@AcuExch.aculab.com> <20161202161921.ace5rolitlxjhr6i@piout.net> In-Reply-To: <20161202161921.ace5rolitlxjhr6i@piout.net> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuExch.aculab.com X-TLS: TLSv1:AES128-SHA:128 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1559 Lines: 39 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 allocated 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/usb/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(struct platform_device *pdev, > > > dev_err(&pdev->dev, "of_probe: name error(%d)\n", ret); > > > goto err; > > > } > > > - ep->ep.name = kasprintf(GFP_KERNEL, "ep%d", ep->index); > > > + ep->ep.name = 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. > > > > IIRC, using statically allocated string is failing somewhere is the USB > 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. David