Re: [PATCH v2] usb: isp1760: Use kasprintf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 7, 2018 at 10:38 AM, Himanshu Jha
<himanshujha199640@xxxxxxxxx> wrote:
> 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@xxxxxxxxx>

Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>

-Kees

> ---
>  drivers/usb/isp1760/isp1760-udc.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> v2:
>    -removed the useless local variable devname.
>
> diff --git a/drivers/usb/isp1760/isp1760-udc.c b/drivers/usb/isp1760/isp1760-udc.c
> index bac4ef5..1714b22 100644
> --- a/drivers/usb/isp1760/isp1760-udc.c
> +++ b/drivers/usb/isp1760/isp1760-udc.c
> @@ -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)
> --
> 2.7.4
>



-- 
Kees Cook
Pixel Security
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux