Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 801822d1 authored by Shyam Saini's avatar Shyam Saini Committed by David S. Miller
Browse files

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: default avatarShyam Saini <mayhs11saini@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5671e8c1
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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)