Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1533953 > unrolled thread
| Started by | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| First post | 2016-12-01 11:30 +0100 |
| Last post | 2016-12-05 18:20 +0100 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] usb: gadget: udc: atmel: used managed kasprintf Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-12-01 11:30 +0100
Re: [PATCH] usb: gadget: udc: atmel: used managed kasprintf Nicolas Ferre <nicolas.ferre@atmel.com> - 2016-12-01 12:30 +0100
RE: [PATCH] usb: gadget: udc: atmel: used managed kasprintf David Laight <David.Laight@ACULAB.COM> - 2016-12-02 17:10 +0100
Re: [PATCH] usb: gadget: udc: atmel: used managed kasprintf Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-12-02 17:30 +0100
RE: [PATCH] usb: gadget: udc: atmel: used managed kasprintf David Laight <David.Laight@ACULAB.COM> - 2016-12-05 18:20 +0100
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2016-12-01 11:30 +0100 |
| Subject | [PATCH] usb: gadget: udc: atmel: used managed kasprintf |
| Message-ID | <sJwMN-2D6-7@gated-at.bofh.it> |
Use devm_kasprintf instead of simple kasprintf to free the allocated memory when needed. Suggested-by: Peter Rosin <peda@axentia.se> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> --- 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); ep->ep_regs = udc->regs + USBA_EPT_BASE(i); ep->dma_regs = udc->regs + USBA_DMA_BASE(i); -- 2.10.2
[toc] | [next] | [standalone]
| From | Nicolas Ferre <nicolas.ferre@atmel.com> |
|---|---|
| Date | 2016-12-01 12:30 +0100 |
| Message-ID | <sJxIR-3bK-5@gated-at.bofh.it> |
| In reply to | #1533953 |
Le 01/12/2016 à 11:26, Alexandre Belloni a écrit : > Use devm_kasprintf instead of simple kasprintf to free the allocated memory > when needed. > > Suggested-by: Peter Rosin <peda@axentia.se> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> > --- > 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); > > ep->ep_regs = udc->regs + USBA_EPT_BASE(i); > ep->dma_regs = udc->regs + USBA_DMA_BASE(i); > -- Nicolas Ferre
[toc] | [prev] | [next] | [standalone]
| From | David Laight <David.Laight@ACULAB.COM> |
|---|---|
| Date | 2016-12-02 17:10 +0100 |
| Message-ID | <sJYzn-64D-1@gated-at.bofh.it> |
| In reply to | #1533953 |
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 <peda@axentia.se> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> > --- > 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. David
[toc] | [prev] | [next] | [standalone]
| From | Alexandre Belloni <alexandre.belloni@free-electrons.com> |
|---|---|
| Date | 2016-12-02 17:30 +0100 |
| Message-ID | <sJYSJ-6cO-9@gated-at.bofh.it> |
| In reply to | #1535043 |
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 <peda@axentia.se> > > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> > > --- > > 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. -- Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
[toc] | [prev] | [next] | [standalone]
| From | David Laight <David.Laight@ACULAB.COM> |
|---|---|
| Date | 2016-12-05 18:20 +0100 |
| Message-ID | <sL55L-7o6-9@gated-at.bofh.it> |
| In reply to | #1535060 |
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 <peda@axentia.se> > > > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> > > > --- > > > 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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web