From patchwork Mon Sep 4 08:12:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Ni X-Patchwork-Id: 13373578 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 F3C83C83F2C for ; Mon, 4 Sep 2023 08:13:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238842AbjIDINF (ORCPT ); Mon, 4 Sep 2023 04:13:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230494AbjIDINF (ORCPT ); Mon, 4 Sep 2023 04:13:05 -0400 Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B0B897; Mon, 4 Sep 2023 01:13:00 -0700 (PDT) Received: from localhost (unknown [124.16.138.129]) by APP-05 (Coremail) with SMTP id zQCowACnrWF3kfVk2CxnCg--.5865S2; Mon, 04 Sep 2023 16:12:39 +0800 (CST) From: Chen Ni To: borisp@nvidia.com, saeedm@nvidia.com, leon@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, sd@queasysnail.net, raeds@nvidia.com, ehakim@nvidia.com, liorna@nvidia.com, phaddad@nvidia.com, atenart@kernel.org Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Chen Ni Subject: [PATCH] net/mlx5e: Add missing check for xa_load Date: Mon, 4 Sep 2023 08:12:10 +0000 Message-Id: <20230904081210.23901-1-nichen@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: zQCowACnrWF3kfVk2CxnCg--.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[124.16.138.129] X-CM-SenderInfo: xqlfxv3q6l2u1dvotugofq/ Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Add check for xa_load() in order to avoid NULL pointer dereference. Fixes: b7c9400cbc48 ("net/mlx5e: Implement MACsec Rx data path using MACsec skb_metadata_dst") Signed-off-by: Chen Ni --- .../net/ethernet/mellanox/mlx5/core/en_accel/macsec.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 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 c9c1db971652..d2467c0bc3c8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c @@ -1673,10 +1673,12 @@ void mlx5e_macsec_offload_handle_rx_skb(struct net_device *netdev, rcu_read_lock(); sc_xarray_element = xa_load(&macsec->sc_xarray, fs_id); - rx_sc = sc_xarray_element->rx_sc; - if (rx_sc) { - dst_hold(&rx_sc->md_dst->dst); - skb_dst_set(skb, &rx_sc->md_dst->dst); + if (sc_xarray_element) { + rx_sc = sc_xarray_element->rx_sc; + if (rx_sc) { + dst_hold(&rx_sc->md_dst->dst); + skb_dst_set(skb, &rx_sc->md_dst->dst); + } } rcu_read_unlock();