1
0
Fork 0

usb: isp1760: Use kasprintf

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 <himanshujha199640@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
hifive-unleashed-5.1
Himanshu Jha 2018-03-08 00:08:24 +05:30 committed by Greg Kroah-Hartman
parent 161c3bc30f
commit 01812ba34a
1 changed files with 1 additions and 5 deletions

View File

@ -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;
@ -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)