media: usb: Use kmemdup instead of duplicating its function.
authorzhong jiang <zhongjiang@huawei.com>
Tue, 18 Sep 2018 15:25:25 +0000 (11:25 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 3 Dec 2018 18:27:17 +0000 (13:27 -0500)
kmemdup has implemented the function that kmalloc() + memcpy().
We prefer to kmemdup rather than code opened implementation.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/usb/dvb-usb-v2/gl861.c

index 0559417..80fed44 100644 (file)
@@ -200,11 +200,10 @@ gl861_i2c_write_ex(struct dvb_usb_device *d, u8 addr, u8 *wbuf, u16 wlen)
        u8 *buf;
        int ret;
 
-       buf = kmalloc(wlen, GFP_KERNEL);
+       buf = kmemdup(wbuf, wlen, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
 
-       memcpy(buf, wbuf, wlen);
        ret = usb_control_msg(d->udev, usb_sndctrlpipe(d->udev, 0),
                                 GL861_REQ_I2C_RAW, GL861_WRITE,
                                 addr << (8 + 1), 0x0100, buf, wlen, 2000);