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 <falakreyaz@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
5877debe27
commit
238a9584e9
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue