lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Wed,  7 Mar 2018 23:38:02 +0530
From:   Himanshu Jha <himanshujha199640@...il.com>
To:     gregkh@...uxfoundation.org
Cc:     felipe.balbi@...ux.intel.com, johan@...nel.org,
        keescook@...omium.org, linux-usb@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Himanshu Jha <himanshujha199640@...il.com>
Subject: [PATCH] usb: isp1760: Use kasprintf

Use kasprintf instead of combination of kmalloc and sprintf and
therefore avoid unnecessary computation of string length.

Signed-off-by: Himanshu Jha <himanshujha199640@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ