Skip to content

Commit

Permalink
usb: isp1760: Use kasprintf
Browse files Browse the repository at this point in the history
Use kasprintf instead of combination of kmalloc and sprintf and
therefore avoid unnecessary computation of string length.
Also, remove the useless local variable.

Signed-off-by: Himanshu Jha <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
himanshujha199640 authored and gregkh committed Mar 9, 2018
1 parent 161c3bc commit 01812ba
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions drivers/usb/isp1760/isp1760-udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,6 @@ int isp1760_udc_register(struct isp1760_device *isp, int irq,
unsigned long irqflags)
{
struct isp1760_udc *udc = &isp->udc;
const char *devname;
int ret;

udc->irq = -1;
Expand All @@ -1455,13 +1454,10 @@ int isp1760_udc_register(struct isp1760_device *isp, int irq,
if (ret < 0)
return ret;

devname = dev_name(isp->dev);
udc->irqname = kmalloc(strlen(devname) + 7, GFP_KERNEL);
udc->irqname = kasprintf(GFP_KERNEL, "%s (udc)", dev_name(isp->dev));
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)
Expand Down

0 comments on commit 01812ba

Please sign in to comment.