net: usb: ch9200: use kmemdup
authorMuhammad Falak R Wani <falakreyaz@gmail.com>
Thu, 19 May 2016 13:56:50 +0000 (19:26 +0530)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 May 2016 23:50:07 +0000 (19:50 -0400)
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 <falakreyaz@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/ch9200.c

index 5e151e6a3e0930fc0d19bef757ae1507925a8de6..8a40202c0a1732850da1b2eb64af21470b9c85b4 100644 (file)
@@ -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,