mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-27 01:11:31 +00:00
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>
This commit is contained in:
parent
5671e8c19c
commit
801822d1be
1 changed files with 1 additions and 2 deletions
|
|
@ -1236,10 +1236,9 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
|
||||||
struct sockaddr *addr;
|
struct sockaddr *addr;
|
||||||
struct scatterlist sg;
|
struct scatterlist sg;
|
||||||
|
|
||||||
addr = kmalloc(sizeof(*addr), GFP_KERNEL);
|
addr = kmemdup(p, sizeof(*addr), GFP_KERNEL);
|
||||||
if (!addr)
|
if (!addr)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
memcpy(addr, p, sizeof(*addr));
|
|
||||||
|
|
||||||
ret = eth_prepare_mac_addr_change(dev, addr);
|
ret = eth_prepare_mac_addr_change(dev, addr);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue