Commit 13c76227 authored by Yang Yingliang's avatar Yang Yingliang Committed by Jakub Kicinski

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: default avatarYang Yingliang <yangyingliang@huawei.com>
Acked-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
Link: https://lore.kernel.org/r/20220914140100.3795545-2-yangyingliang@huawei.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 46ff47bc
...@@ -931,14 +931,13 @@ static int mlx5e_macsec_add_secy(struct macsec_context *ctx) ...@@ -931,14 +931,13 @@ static int mlx5e_macsec_add_secy(struct macsec_context *ctx)
goto out; 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) { if (!macsec_device->dev_addr) {
kfree(macsec_device); kfree(macsec_device);
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
memcpy(macsec_device->dev_addr, dev->dev_addr, dev->addr_len);
macsec_device->netdev = dev; macsec_device->netdev = dev;
INIT_LIST_HEAD_RCU(&macsec_device->macsec_rx_sc_list_head); INIT_LIST_HEAD_RCU(&macsec_device->macsec_rx_sc_list_head);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment