From patchwork Wed Sep 14 14:00:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 12976172 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4BE3C6FA8B for ; Wed, 14 Sep 2022 13:53:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229549AbiINNxz (ORCPT ); Wed, 14 Sep 2022 09:53:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbiINNxt (ORCPT ); Wed, 14 Sep 2022 09:53:49 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4378D63F36; Wed, 14 Sep 2022 06:53:48 -0700 (PDT) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MSMFW4tP9zHnr0; Wed, 14 Sep 2022 21:51:43 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 14 Sep 2022 21:53:45 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 14 Sep 2022 21:53:45 +0800 From: Yang Yingliang To: , CC: , , , Subject: [PATCH -next v2 1/2] net/mlx5e: add missing error code in error path Date: Wed, 14 Sep 2022 22:00:59 +0800 Message-ID: <20220914140100.3795545-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add missing error code when mlx5e_macsec_fs_add_rule() or mlx5e_macsec_fs_init() fails. mlx5e_macsec_fs_init() don't return ERR_PTR(), so replace IS_ERR_OR_NULL() check with NULL pointer check. Fixes: e467b283ffd5 ("net/mlx5e: Add MACsec TX steering rules") Signed-off-by: Yang Yingliang Acked-by: Saeed Mahameed --- v2: Replace IS_ERR_OR_NULL() check with NULL pointer check. --- drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c | 8 ++++++-- 1 file changed, 6 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 d9d18b039d8c..100e03eb740b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c @@ -194,8 +194,10 @@ static int mlx5e_macsec_init_sa(struct macsec_context *ctx, MLX5_ACCEL_MACSEC_ACTION_DECRYPT; macsec_rule = mlx5e_macsec_fs_add_rule(macsec->macsec_fs, ctx, &rule_attrs, &sa->fs_id); - if (IS_ERR_OR_NULL(macsec_rule)) + if (!macsec_rule) { + err = -ENOMEM; goto destroy_macsec_object; + } sa->macsec_rule = macsec_rule; @@ -1294,8 +1296,10 @@ int mlx5e_macsec_init(struct mlx5e_priv *priv) macsec->mdev = mdev; macsec_fs = mlx5e_macsec_fs_init(mdev, priv->netdev); - if (IS_ERR_OR_NULL(macsec_fs)) + if (!macsec_fs) { + err = -ENOMEM; goto err_out; + } macsec->macsec_fs = macsec_fs; From patchwork Wed Sep 14 14:01:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 12976171 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E651ECAAD3 for ; Wed, 14 Sep 2022 13:53:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229522AbiINNxy (ORCPT ); Wed, 14 Sep 2022 09:53:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229734AbiINNxt (ORCPT ); Wed, 14 Sep 2022 09:53:49 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7797974357; Wed, 14 Sep 2022 06:53:48 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MSMFX0nXPzHnrB; Wed, 14 Sep 2022 21:51:44 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 14 Sep 2022 21:53:46 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 14 Sep 2022 21:53:45 +0800 From: Yang Yingliang To: , CC: , , , Subject: [PATCH -next v2 2/2] net/mlx5e: Switch to kmemdup() when allocate dev_addr Date: Wed, 14 Sep 2022 22:01:00 +0800 Message-ID: <20220914140100.3795545-2-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220914140100.3795545-1-yangyingliang@huawei.com> References: <20220914140100.3795545-1-yangyingliang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Use kmemdup() helper instead of open-coding to simplify the code when allocate dev_addr. Signed-off-by: Yang Yingliang Acked-by: Saeed Mahameed --- 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);