diff mbox series

[-next,v2,2/2] net/mlx5e: Switch to kmemdup() when allocate dev_addr

Message ID 20220914140100.3795545-2-yangyingliang@huawei.com (mailing list archive)
State Accepted
Commit 13c76227cd8a14c5aa092387575cc3cab8eba5b4
Delegated to: Netdev Maintainers
Headers show
Series [-next,v2,1/2] net/mlx5e: add missing error code in error path | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/cc_maintainers warning 5 maintainers not CCed: edumazet@google.com borisp@nvidia.com pabeni@redhat.com leon@kernel.org kuba@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch warning WARNING: line length of 84 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yang Yingliang Sept. 14, 2022, 2:01 p.m. UTC
Use kmemdup() helper instead of open-coding to
simplify the code when allocate dev_addr.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
v2:
 Make kmemdup() fit in one line.
---
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Saeed Mahameed Sept. 14, 2022, 8:10 p.m. UTC | #1
On 14 Sep 22:01, Yang Yingliang wrote:
>Use kmemdup() helper instead of open-coding to
>simplify the code when allocate dev_addr.
>
>Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>---
>v2:
> Make kmemdup() fit in one line.
>---

Acked-by: Saeed Mahameed <saeedm@nvidia.com>                                    
                                                                                 
netdev maintainers please apply directly.                                       
                                                                                 
Thanks.
diff mbox series

Patch

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);