提交 801822d1 编写于 作者: S Shyam Saini 提交者: David S. Miller

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: NShyam Saini <mayhs11saini@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 5671e8c1
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册