aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Yingliang <[email protected]>2022-09-14 22:01:00 +0800
committerJakub Kicinski <[email protected]>2022-09-19 17:58:40 -0700
commit13c76227cd8a14c5aa092387575cc3cab8eba5b4 (patch)
tree5f82fd107579178c7060935241c8bcdba806b7a4
parent46ff47bc81b4f2eaddaf5e6744f88f86c9eb7946 (diff)
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 <[email protected]> Acked-by: Saeed Mahameed <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
index 100e03eb740b..ea362072a984 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
@@ -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);