From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 136B5A00C5; Tue, 4 Jan 2022 09:20:46 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3479C4115F; Tue, 4 Jan 2022 09:19:41 +0100 (CET) Received: from relay.smtp-ext.broadcom.com (relay.smtp-ext.broadcom.com [192.19.166.231]) by mails.dpdk.org (Postfix) with ESMTP id 346E8426D2 for ; Tue, 4 Jan 2022 09:19:40 +0100 (CET) Received: from dhcp-10-123-153-22.dhcp.broadcom.net (bgccx-dev-host-lnx2.bec.broadcom.net [10.123.153.22]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 1B789C0000F1; Tue, 4 Jan 2022 00:19:37 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 1B789C0000F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1641284379; bh=89c/SyylRj+ilzHwRurZLc8vRJ+Hi3R1YDjDfwexGD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DF6B4Oy0Ll0dRMmCQxFyF5ugL03DUMi1dm4cKkLQhMPUBvkua4uMKnQPUGABSBQBl veQ5qMzOttlxeGdbPb+CGP3P4WS73WY2VdDkfPmyi5Zv2RoU/pEX3mlNGTgXGkaas9 H4YGkV5wWMw6Cb8BAPk2V5j1IFjLrOO+KA0IloD8= From: Kalesh A P To: dev@dpdk.org Cc: ferruh.yigit@intel.com, ajit.khaparde@broadcom.com Subject: [dpdk-dev] [PATCH 18/18] net/bnxt: check VF rep pointer before access Date: Tue, 4 Jan 2022 14:08:24 +0530 Message-Id: <20220104083824.23001-19-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20220104083824.23001-1-kalesh-anakkur.purayil@broadcom.com> References: <20220104083824.23001-1-kalesh-anakkur.purayil@broadcom.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Ajit Khaparde The PF or trusted VF Rx handler could invoke the VF representor's Rx function without knowledge of the application cleaning up the representor ports. Check if the vfr_bp pointer is valid before accessing it. Fixes: 6dc83230b43b ("net/bnxt: support port representor data path") Cc: stable@dpdk.org Signed-off-by: Ajit Khaparde Reviewed-by: Kalesh AP Reviewed-by: Somnath Kotur --- drivers/net/bnxt/bnxt_reps.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c index f24f5ef..5e140f0 100644 --- a/drivers/net/bnxt/bnxt_reps.c +++ b/drivers/net/bnxt/bnxt_reps.c @@ -35,16 +35,20 @@ static const struct eth_dev_ops bnxt_rep_dev_ops = { uint16_t bnxt_vfr_recv(uint16_t port_id, uint16_t queue_id, struct rte_mbuf *mbuf) { - struct rte_mbuf **prod_rx_buf; + struct bnxt_representor *vfr_bp = NULL; struct bnxt_rx_ring_info *rep_rxr; - struct bnxt_rx_queue *rep_rxq; struct rte_eth_dev *vfr_eth_dev; - struct bnxt_representor *vfr_bp; + struct rte_mbuf **prod_rx_buf; + struct bnxt_rx_queue *rep_rxq; uint16_t mask; uint8_t que; vfr_eth_dev = &rte_eth_devices[port_id]; - vfr_bp = vfr_eth_dev->data->dev_private; + vfr_bp = vfr_eth_dev ? vfr_eth_dev->data->dev_private : NULL; + + if (unlikely(vfr_bp == NULL)) + return 1; + /* If rxq_id happens to be > nr_rings, use ring 0 */ que = queue_id < vfr_bp->rx_nr_rings ? queue_id : 0; rep_rxq = vfr_bp->rx_queues[que]; -- 2.10.1