* [PATCH] usb: isp1760: Use kasprintf
@ 2018-03-07 18:08 ` Himanshu Jha
0 siblings, 0 replies; 6+ messages in thread
From: Himanshu Jha @ 2018-03-07 18:08 UTC (permalink / raw)
To: gregkh
Cc: felipe.balbi, johan, keescook, linux-usb, linux-kernel, Himanshu Jha
Use kasprintf instead of combination of kmalloc and sprintf and
therefore avoid unnecessary computation of string length.
Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
---
drivers/usb/isp1760/isp1760-udc.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/usb/isp1760/isp1760-udc.c b/drivers/usb/isp1760/isp1760-udc.c
index bac4ef5..c35b153 100644
--- a/drivers/usb/isp1760/isp1760-udc.c
+++ b/drivers/usb/isp1760/isp1760-udc.c
@@ -1456,12 +1456,10 @@ int isp1760_udc_register(struct isp1760_device *isp, int irq,
return ret;
devname = dev_name(isp->dev);
- udc->irqname = kmalloc(strlen(devname) + 7, GFP_KERNEL);
+ udc->irqname = kasprintf(GFP_KERNEL, "%s (udc)", devname);
if (!udc->irqname)
return -ENOMEM;
- sprintf(udc->irqname, "%s (udc)", devname);
-
ret = request_irq(irq, isp1760_udc_irq, IRQF_SHARED | irqflags,
udc->irqname, udc);
if (ret < 0)
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* usb: isp1760: Use kasprintf
@ 2018-03-07 18:08 ` Himanshu Jha
0 siblings, 0 replies; 6+ messages in thread
From: Himanshu Jha @ 2018-03-07 18:08 UTC (permalink / raw)
To: gregkh
Cc: felipe.balbi, johan, keescook, linux-usb, linux-kernel, Himanshu Jha
Use kasprintf instead of combination of kmalloc and sprintf and
therefore avoid unnecessary computation of string length.
Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
---
drivers/usb/isp1760/isp1760-udc.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/usb/isp1760/isp1760-udc.c b/drivers/usb/isp1760/isp1760-udc.c
index bac4ef5..c35b153 100644
--- a/drivers/usb/isp1760/isp1760-udc.c
+++ b/drivers/usb/isp1760/isp1760-udc.c
@@ -1456,12 +1456,10 @@ int isp1760_udc_register(struct isp1760_device *isp, int irq,
return ret;
devname = dev_name(isp->dev);
- udc->irqname = kmalloc(strlen(devname) + 7, GFP_KERNEL);
+ udc->irqname = kasprintf(GFP_KERNEL, "%s (udc)", devname);
if (!udc->irqname)
return -ENOMEM;
- sprintf(udc->irqname, "%s (udc)", devname);
-
ret = request_irq(irq, isp1760_udc_irq, IRQF_SHARED | irqflags,
udc->irqname, udc);
if (ret < 0)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: isp1760: Use kasprintf
@ 2018-03-07 18:20 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2018-03-07 18:20 UTC (permalink / raw)
To: Himanshu Jha
Cc: Greg Kroah-Hartman, Felipe Balbi, Johan Hovold, Kees Cook, USB,
Linux Kernel Mailing List
On Wed, Mar 7, 2018 at 8:08 PM, Himanshu Jha
<himanshujha199640@gmail.com> wrote:
> Use kasprintf instead of combination of kmalloc and sprintf and
> therefore avoid unnecessary computation of string length.
> devname = dev_name(isp->dev);
Do you still need this temporary variable?
> - udc->irqname = kmalloc(strlen(devname) + 7, GFP_KERNEL);
> + udc->irqname = kasprintf(GFP_KERNEL, "%s (udc)", devname);
Perhaps
devname -> dev_name(isp->dev)
?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* usb: isp1760: Use kasprintf
@ 2018-03-07 18:20 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2018-03-07 18:20 UTC (permalink / raw)
To: Himanshu Jha
Cc: Greg Kroah-Hartman, Felipe Balbi, Johan Hovold, Kees Cook, USB,
Linux Kernel Mailing List
On Wed, Mar 7, 2018 at 8:08 PM, Himanshu Jha
<himanshujha199640@gmail.com> wrote:
> Use kasprintf instead of combination of kmalloc and sprintf and
> therefore avoid unnecessary computation of string length.
> devname = dev_name(isp->dev);
Do you still need this temporary variable?
> - udc->irqname = kmalloc(strlen(devname) + 7, GFP_KERNEL);
> + udc->irqname = kasprintf(GFP_KERNEL, "%s (udc)", devname);
Perhaps
devname -> dev_name(isp->dev)
?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: isp1760: Use kasprintf
@ 2018-03-07 18:30 ` Himanshu Jha
0 siblings, 0 replies; 6+ messages in thread
From: Himanshu Jha @ 2018-03-07 18:30 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Greg Kroah-Hartman, Felipe Balbi, Johan Hovold, Kees Cook, USB,
Linux Kernel Mailing List
On Wed, Mar 07, 2018 at 08:20:54PM +0200, Andy Shevchenko wrote:
> On Wed, Mar 7, 2018 at 8:08 PM, Himanshu Jha
> <himanshujha199640@gmail.com> wrote:
> > Use kasprintf instead of combination of kmalloc and sprintf and
> > therefore avoid unnecessary computation of string length.
>
> > devname = dev_name(isp->dev);
>
> Do you still need this temporary variable?
No.
> > - udc->irqname = kmalloc(strlen(devname) + 7, GFP_KERNEL);
> > + udc->irqname = kasprintf(GFP_KERNEL, "%s (udc)", devname);
>
> Perhaps
>
> devname -> dev_name(isp->dev)
>
> ?
Oh, yes!
Thanks for pointing that out.
I will send v2 with the update!
--
Thanks
Himanshu Jha
^ permalink raw reply [flat|nested] 6+ messages in thread
* usb: isp1760: Use kasprintf
@ 2018-03-07 18:30 ` Himanshu Jha
0 siblings, 0 replies; 6+ messages in thread
From: Himanshu Jha @ 2018-03-07 18:30 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Greg Kroah-Hartman, Felipe Balbi, Johan Hovold, Kees Cook, USB,
Linux Kernel Mailing List
On Wed, Mar 07, 2018 at 08:20:54PM +0200, Andy Shevchenko wrote:
> On Wed, Mar 7, 2018 at 8:08 PM, Himanshu Jha
> <himanshujha199640@gmail.com> wrote:
> > Use kasprintf instead of combination of kmalloc and sprintf and
> > therefore avoid unnecessary computation of string length.
>
> > devname = dev_name(isp->dev);
>
> Do you still need this temporary variable?
No.
> > - udc->irqname = kmalloc(strlen(devname) + 7, GFP_KERNEL);
> > + udc->irqname = kasprintf(GFP_KERNEL, "%s (udc)", devname);
>
> Perhaps
>
> devname -> dev_name(isp->dev)
>
> ?
Oh, yes!
Thanks for pointing that out.
I will send v2 with the update!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-03-07 18:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-07 18:08 [PATCH] usb: isp1760: Use kasprintf Himanshu Jha
2018-03-07 18:08 ` Himanshu Jha
2018-03-07 18:20 ` [PATCH] " Andy Shevchenko
2018-03-07 18:20 ` Andy Shevchenko
2018-03-07 18:30 ` [PATCH] " Himanshu Jha
2018-03-07 18:30 ` Himanshu Jha
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.