ieee802154: Use kmemdup instead of duplicating it in ca8210_test_int_driver_write
authorYueHaibing <yuehaibing@huawei.com>
Thu, 9 Aug 2018 06:44:29 +0000 (14:44 +0800)
committerStefan Schmidt <stefan@datenfreihafen.org>
Fri, 21 Sep 2018 08:52:15 +0000 (10:52 +0200)
Replace calls to kmalloc followed by a memcpy with a direct call to
kmemdup.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
drivers/net/ieee802154/ca8210.c

index 58299fb666ed4d84fb7ea01a76aabb86575ab939..e21279dde85c2cf687a301f1ac43a0645c09f344 100644 (file)
@@ -634,10 +634,9 @@ static int ca8210_test_int_driver_write(
        for (i = 0; i < len; i++)
                dev_dbg(&priv->spi->dev, "%#03x\n", buf[i]);
 
-       fifo_buffer = kmalloc(len, GFP_KERNEL);
+       fifo_buffer = kmemdup(buf, len, GFP_KERNEL);
        if (!fifo_buffer)
                return -ENOMEM;
-       memcpy(fifo_buffer, buf, len);
        kfifo_in(&test->up_fifo, &fifo_buffer, 4);
        wake_up_interruptible(&priv->test.readq);