From: Muhammad Falak R Wani Date: Thu, 19 May 2016 13:56:50 +0000 (+0530) Subject: net: usb: ch9200: use kmemdup X-Git-Tag: v4.7-rc1~96^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=238a9584e9e2c7b3ea23924e9183fee05d584789;p=thirdparty%2Fkernel%2Flinux.git net: usb: ch9200: use kmemdup Use kmemdup when some other buffer is immediately copied into allocated region. It replaces call to allocation followed by memcpy, by a single call to kmemdup. Signed-off-by: Muhammad Falak R Wani Signed-off-by: David S. Miller --- diff --git a/drivers/net/usb/ch9200.c b/drivers/net/usb/ch9200.c index 5e151e6a3e093..8a40202c0a173 100644 --- a/drivers/net/usb/ch9200.c +++ b/drivers/net/usb/ch9200.c @@ -155,12 +155,11 @@ static int control_write(struct usbnet *dev, unsigned char request, index, size); if (data) { - buf = kmalloc(size, GFP_KERNEL); + buf = kmemdup(data, size, GFP_KERNEL); if (!buf) { err = -ENOMEM; goto err_out; } - memcpy(buf, data, size); } err = usb_control_msg(dev->udev,