Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: <netdev@vger.kernel.org>, <linux-rdma@vger.kernel.org>
Cc: <saeedm@nvidia.com>, <liorna@nvidia.com>, <raeds@nvidia.com>,
	<davem@davemloft.net>
Subject: [PATCH -next v2 2/2] net/mlx5e: Switch to kmemdup() when allocate dev_addr
Date: Wed, 14 Sep 2022 22:01:00 +0800	[thread overview]
Message-ID: <20220914140100.3795545-2-yangyingliang@huawei.com> (raw)
In-Reply-To: <20220914140100.3795545-1-yangyingliang@huawei.com>

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

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


  reply	other threads:[~2022-09-14 13:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14 14:00 [PATCH -next v2 1/2] net/mlx5e: add missing error code in error path Yang Yingliang
2022-09-14 14:01 ` Yang Yingliang [this message]
2022-09-14 20:10   ` [PATCH -next v2 2/2] net/mlx5e: Switch to kmemdup() when allocate dev_addr Saeed Mahameed
2022-09-14 20:10 ` [PATCH -next v2 1/2] net/mlx5e: add missing error code in error path Saeed Mahameed
2022-09-20  1:10 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220914140100.3795545-2-yangyingliang@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=davem@davemloft.net \
    --cc=linux-rdma@vger.kernel.org \
    --cc=liorna@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=raeds@nvidia.com \
    --cc=saeedm@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox