From: Shyam Saini Date: Fri, 23 Dec 2016 19:14:58 +0000 (+0530) Subject: net: Use kmemdup instead of kmalloc and memcpy X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=801822d1beea4f11a38df991b420ca917f6a917b;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git net: Use kmemdup instead of kmalloc and memcpy when some other buffer is immediately copied into allocated region. Replace calls to kmalloc followed by a memcpy with a direct call to kmemdup. Signed-off-by: Shyam Saini Signed-off-by: David S. Miller --- diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 4a105006ca63..2cea022e6e6e 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -1236,10 +1236,9 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p) struct sockaddr *addr; struct scatterlist sg; - addr = kmalloc(sizeof(*addr), GFP_KERNEL); + addr = kmemdup(p, sizeof(*addr), GFP_KERNEL); if (!addr) return -ENOMEM; - memcpy(addr, p, sizeof(*addr)); ret = eth_prepare_mac_addr_change(dev, addr); if (ret)