net/mlx5e: Switch to kmemdup() when allocate dev_addr
Use kmemdup() helper instead of open-coding to simplify the code when allocate dev_addr. Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Acked-by: Saeed Mahameed <saeedm@nvidia.com> Link: https://lore.kernel.org/r/20220914140100.3795545-2-yangyingliang@huawei.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
46ff47bc81
commit
13c76227cd
@ -931,14 +931,13 @@ static int mlx5e_macsec_add_secy(struct macsec_context *ctx)
|
||||
goto out;
|
||||
}
|
||||
|
||||
macsec_device->dev_addr = kzalloc(dev->addr_len, GFP_KERNEL);
|
||||
macsec_device->dev_addr = kmemdup(dev->dev_addr, dev->addr_len, GFP_KERNEL);
|
||||
if (!macsec_device->dev_addr) {
|
||||
kfree(macsec_device);
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(macsec_device->dev_addr, dev->dev_addr, dev->addr_len);
|
||||
macsec_device->netdev = dev;
|
||||
|
||||
INIT_LIST_HEAD_RCU(&macsec_device->macsec_rx_sc_list_head);
|
||||
|
Loading…
Reference in New Issue
Block a user