Commit d6c4dc3b authored by Muhammad Falak R Wani's avatar Muhammad Falak R Wani Committed by Johan Hovold

USB: serial: cp210x: 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: default avatarMuhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent d8d841e8
...@@ -496,12 +496,10 @@ static int cp210x_write_reg_block(struct usb_serial_port *port, u8 req, ...@@ -496,12 +496,10 @@ static int cp210x_write_reg_block(struct usb_serial_port *port, u8 req,
void *dmabuf; void *dmabuf;
int result; int result;
dmabuf = kmalloc(bufsize, GFP_KERNEL); dmabuf = kmemdup(buf, bufsize, GFP_KERNEL);
if (!dmabuf) if (!dmabuf)
return -ENOMEM; return -ENOMEM;
memcpy(dmabuf, buf, bufsize);
result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
req, REQTYPE_HOST_TO_INTERFACE, 0, req, REQTYPE_HOST_TO_INTERFACE, 0,
port_priv->bInterfaceNumber, dmabuf, bufsize, port_priv->bInterfaceNumber, dmabuf, bufsize,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment