Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1926098rdb; Tue, 5 Sep 2023 09:02:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFATnif6euw84acBMvZTf2sI2JzDLJQAGuWax1OcHplx5hJE/sXR01GjJZGMUS2nW9y/l7N X-Received: by 2002:a05:6a21:3e01:b0:147:5ab9:8496 with SMTP id bk1-20020a056a213e0100b001475ab98496mr10240168pzc.55.1693929729376; Tue, 05 Sep 2023 09:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693929729; cv=none; d=google.com; s=arc-20160816; b=OH6hhNBE7r38Z7dxVVTlsh8wC3KgUhJdygDyNgJfEOAUzf2/tlvjd8s/r2JD3ZFLoF aDxQyBgBrvFlxYwCeGwdU1Vw0iyAcQdsJRHhKSGwGZMysgq5LmhZkHHCbKWRu994+wn7 bTo2asJsTB5/GOf1XhVcAXUoS/i3Fu1eJtfMfIzhpN9YPpCOl0oSpflPrXNEAFh4C+n9 WgIqk5AdvRG/aU7D7DOA3+0GSnnviGNCxWlX32XNt4OookNdXBmpTIYZWxnBD2EVgcfN aq833EMQxUNwgns7292inWxk+gFvb2zEJebg5MWF+uOP8X3kXjiyD1rS0wqcMjJZqbkM 40xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=bIYT4SCBFUNiV+SXnQ2gl9GlZNjCM5jn0+lT9Z80hdk=; fh=D3Kou27GMPkM61gfBvvNJK9uP2riKRbji57YYVNVdlU=; b=HWVS1+yqLD09fczDOpyYh1jUInBiZy1ubW2Sh+aDsP8GER13QMM4axe/Bf0yWkqx4M 7TYm7tSpvTDD83ItO5Aj0qSmC3XvSTeJNbXKWn6B1X3+2wkyYziQAgfj0skDO8j6QBAU pFH9RTR/7Rk0DxYu5BJA+VylD6Lt+zzgMNC5qLMZfXk5VqzIWFzAf++oVGmXzHqtP4dE 8I4fCIDO/XbImRP5h+6/AaemW6uQEGuzlAy5yDD9M9US3nTWYiRP2VyIexhKwuKMnB1k GEXLWUzgdkrwulVHCqf3LxAzvuPc9nkInKpaKE2MY8f0Pd3nOcWkRB7xSJZM8q8BQjIk EVLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 2-20020a631642000000b005704fe629ccsi9845416pgw.174.2023.09.05.09.02.06; Tue, 05 Sep 2023 09:02:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345768AbjIDINF (ORCPT + 14 others); 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 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowACnrWF3kfVk2CxnCg--.5865S2 X-Coremail-Antispam: 1UD129KBjvJXoW7XrW7JrW5Ww18XryrXF4fZrb_yoW8Jr13pr 17AFW7uF1kGw1xXayUZ3y8Wr15Jw4vqa9a9a4fA3yfXw1DArW7Ary5GFy7Arn0krW5CF4q vwn2v3W3Xan8Jr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvG14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCY02Avz4vE14v_GFyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r4a6rW5MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjfUYv38UUUUU X-Originating-IP: [124.16.138.129] X-CM-SenderInfo: xqlfxv3q6l2u1dvotugofq/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(); -- 2.25.1