DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@amd.com, thomas@monjalon.net,
	Kalesh AP <kalesh-anakkur.purayil@broadcom.com>,
	stable@dpdk.org, Somnath Kotur <somnath.kotur@broadcom.com>
Subject: [PATCH 05/10] net/bnxt: fix a null pointer dereference
Date: Wed, 21 Feb 2024 13:20:40 -0800	[thread overview]
Message-ID: <20240221212044.27209-6-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20240221212044.27209-1-ajit.khaparde@broadcom.com>

[-- Attachment #1: Type: text/plain, Size: 2400 bytes --]

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

In the recent changes to rte_eth_dev_release_port() the library sets
eth_dev->data to NULL at the end of the routine. This causes a NULL
pointer dereference in the bnxt_rep_dev_info_get_op() and
bnxt_representor_uninit() routines when it tries to validate parent dev.

Add code to handle this.

Fixes: 6dc83230b43b ("net/bnxt: support port representor data path")
Cc: stable@dpdk.org

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/bnxt_reps.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
index 3a4720bc3c..edcc27f556 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -32,6 +32,14 @@ static const struct eth_dev_ops bnxt_rep_dev_ops = {
 	.flow_ops_get = bnxt_flow_ops_get_op
 };
 
+static bool bnxt_rep_check_parent(struct bnxt_representor *rep)
+{
+	if (!rep->parent_dev->data->dev_private)
+		return false;
+
+	return true;
+}
+
 uint16_t
 bnxt_vfr_recv(uint16_t port_id, uint16_t queue_id, struct rte_mbuf *mbuf)
 {
@@ -266,12 +274,12 @@ int bnxt_representor_uninit(struct rte_eth_dev *eth_dev)
 	PMD_DRV_LOG(DEBUG, "BNXT Port:%d VFR uninit\n", eth_dev->data->port_id);
 	eth_dev->data->mac_addrs = NULL;
 
-	parent_bp = rep->parent_dev->data->dev_private;
-	if (!parent_bp) {
+	if (!bnxt_rep_check_parent(rep)) {
 		PMD_DRV_LOG(DEBUG, "BNXT Port:%d already freed\n",
 			    eth_dev->data->port_id);
 		return 0;
 	}
+	parent_bp = rep->parent_dev->data->dev_private;
 
 	parent_bp->num_reps--;
 	vf_id = rep->vf_id;
@@ -539,11 +547,12 @@ int bnxt_rep_dev_info_get_op(struct rte_eth_dev *eth_dev,
 	int rc = 0;
 
 	/* MAC Specifics */
-	parent_bp = rep_bp->parent_dev->data->dev_private;
-	if (!parent_bp) {
-		PMD_DRV_LOG(ERR, "Rep parent NULL!\n");
+	if (!bnxt_rep_check_parent(rep_bp)) {
+		/* Need not be an error scenario, if parent is closed first */
+		PMD_DRV_LOG(INFO, "Rep parent port does not exist.\n");
 		return rc;
 	}
+	parent_bp = rep_bp->parent_dev->data->dev_private;
 	PMD_DRV_LOG(DEBUG, "Representor dev_info_get_op\n");
 	dev_info->max_mac_addrs = parent_bp->max_l2_ctx;
 	dev_info->max_hash_mac_addrs = 0;
-- 
2.39.2 (Apple Git-143)


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4218 bytes --]

  parent reply	other threads:[~2024-02-21 21:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 21:20 [PATCH 00/10] patchset for bnxt Ajit Khaparde
2024-02-21 21:20 ` [PATCH 01/10] net/bnxt: extend long bd check for VXLAN GPE Ajit Khaparde
2024-02-21 21:20 ` [PATCH 02/10] net/bnxt: add dual rate module detection log Ajit Khaparde
2024-02-21 21:20 ` [PATCH 03/10] net/bnxt: increase queue size for async handling Ajit Khaparde
2024-02-21 21:20 ` [PATCH 04/10] net/bnxt: fix AGG ID computation Ajit Khaparde
2024-02-21 21:20 ` Ajit Khaparde [this message]
2024-02-21 21:20 ` [PATCH 06/10] net/bnxt: handle UDP GSO Tx Ajit Khaparde
2024-02-21 21:20 ` [PATCH 07/10] net/bnxt: add IPv6 flow label based RSS support Ajit Khaparde
2024-02-21 21:20 ` [PATCH 08/10] net/bnxt: fix compressed CQE handling Ajit Khaparde
2024-02-21 21:20 ` [PATCH 09/10] net/bnxt: fix compressed Rx " Ajit Khaparde
2024-02-21 21:20 ` [PATCH 10/10] doc: update release notes for bnxt Ajit Khaparde
2024-02-22 19:47 ` [PATCH v2 00/10] patchset " Ajit Khaparde
2024-02-22 19:47   ` [PATCH v2 01/10] net/bnxt: extend long bd check for VXLAN GPE Ajit Khaparde
2024-02-22 19:47   ` [PATCH v2 02/10] net/bnxt: add dual rate module detection log Ajit Khaparde
2024-02-22 19:47   ` [PATCH v2 03/10] net/bnxt: increase queue size for async handling Ajit Khaparde
2024-02-22 19:47   ` [PATCH v2 04/10] net/bnxt: fix AGG ID computation Ajit Khaparde
2024-02-22 19:47   ` [PATCH v2 05/10] net/bnxt: fix a null pointer dereference Ajit Khaparde
2024-02-22 19:47   ` [PATCH v2 06/10] net/bnxt: handle UDP GSO Tx Ajit Khaparde
2024-02-22 19:47   ` [PATCH v2 07/10] net/bnxt: add IPv6 flow label based RSS support Ajit Khaparde
2024-02-22 19:47   ` [PATCH v2 08/10] net/bnxt: fix compressed CQE handling Ajit Khaparde
2024-02-22 19:47   ` [PATCH v2 09/10] net/bnxt: fix compressed Rx " Ajit Khaparde
2024-02-22 19:48   ` [PATCH v2 10/10] doc: update release notes for bnxt Ajit Khaparde
2024-02-23  2:05   ` [PATCH v2 00/10] patchset " Ajit Khaparde

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=20240221212044.27209-6-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=somnath.kotur@broadcom.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /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;
as well as URLs for NNTP newsgroup(s).