summaryrefslogtreecommitdiffstats
path: root/drivers/net/virtio_net.c
diff options
context:
space:
mode:
authorShyam Saini <mayhs11saini@gmail.com>2016-12-24 00:44:58 +0530
committerDavid S. Miller <davem@davemloft.net>2016-12-29 11:37:14 -0500
commit801822d1beea4f11a38df991b420ca917f6a917b (patch)
tree2e8ccd20864425053597d8c8448151463f7f7f70 /drivers/net/virtio_net.c
parent5671e8c19c8cb4dd432e54f5bc5e2e9a9bac894b (diff)
downloadlinux-801822d1beea4f11a38df991b420ca917f6a917b.tar.bz2
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 <mayhs11saini@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/virtio_net.c')
-rw-r--r--drivers/net/virtio_net.c3
1 files changed, 1 insertions, 2 deletions
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)