Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Selvin Xavier <selvin.xavier@broadcom.com>
To: leon@kernel.org, jgg@ziepe.ca
Cc: linux-rdma@vger.kernel.org, andrew.gospodarek@broadcom.com,
	kalesh-anakkur.purayil@broadcom.com,
	Selvin Xavier <selvin.xavier@broadcom.com>
Subject: [PATCH rdma-rc 2/4] RDMA/bnxt_re: Add sanity checks on rdev validity
Date: Tue,  4 Feb 2025 00:21:23 -0800	[thread overview]
Message-ID: <1738657285-23968-3-git-send-email-selvin.xavier@broadcom.com> (raw)
In-Reply-To: <1738657285-23968-1-git-send-email-selvin.xavier@broadcom.com>

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

There is a possibility that ulp_irq_stop and ulp_irq_start
callbacks will be called when the device is in detached state.
This can cause a crash due to NULL pointer dereference as
the rdev is already freed.

Fixes: cc5b9b48d447 ("RDMA/bnxt_re: Recover the device when FW error is detected")
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
---
 drivers/infiniband/hw/bnxt_re/main.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c
index c4c3d67..89ac5c2 100644
--- a/drivers/infiniband/hw/bnxt_re/main.c
+++ b/drivers/infiniband/hw/bnxt_re/main.c
@@ -438,6 +438,8 @@ static void bnxt_re_stop_irq(void *handle, bool reset)
 	int indx;
 
 	rdev = en_info->rdev;
+	if (!rdev)
+		return;
 	rcfw = &rdev->rcfw;
 
 	if (reset) {
@@ -466,6 +468,8 @@ static void bnxt_re_start_irq(void *handle, struct bnxt_msix_entry *ent)
 	int indx, rc;
 
 	rdev = en_info->rdev;
+	if (!rdev)
+		return;
 	msix_ent = rdev->nqr->msix_entries;
 	rcfw = &rdev->rcfw;
 	if (!ent) {
@@ -2438,6 +2442,7 @@ static int bnxt_re_suspend(struct auxiliary_device *adev, pm_message_t state)
 	ibdev_info(&rdev->ibdev, "%s: L2 driver notified to stop en_state 0x%lx",
 		   __func__, en_dev->en_state);
 	bnxt_re_remove_device(rdev, BNXT_RE_PRE_RECOVERY_REMOVE, adev);
+	bnxt_re_update_en_info_rdev(NULL, en_info, adev);
 	mutex_unlock(&bnxt_re_mutex);
 
 	return 0;
-- 
2.5.5


  parent reply	other threads:[~2025-02-04  8:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04  8:21 [PATCH rdma-rc 0/4] RDMA/bnxt_re: Bug fixes for 6.14 Selvin Xavier
2025-02-04  8:21 ` [PATCH rdma-rc 1/4] RDMA/bnxt_re: Fix an issue in bnxt_re_async_notifier Selvin Xavier
2025-02-04  8:21 ` Selvin Xavier [this message]
2025-02-04 11:44   ` [PATCH rdma-rc 2/4] RDMA/bnxt_re: Add sanity checks on rdev validity Leon Romanovsky
2025-02-04 16:40     ` Kalesh Anakkur Purayil
2025-02-05  7:17       ` Leon Romanovsky
2025-02-05  8:24         ` Kalesh Anakkur Purayil
2025-02-05  9:52           ` Leon Romanovsky
2025-02-05 16:15             ` Kalesh Anakkur Purayil
2025-02-09 17:18               ` Selvin Xavier
2025-02-09 20:05                 ` Leon Romanovsky
2025-02-05 14:47           ` Jason Gunthorpe
2025-02-05 16:20             ` Kalesh Anakkur Purayil
2025-02-04  8:21 ` [PATCH rdma-rc 3/4] RDMA/bnxt_re: Fix issue in the unload path Selvin Xavier
2025-02-25 18:42   ` Jason Gunthorpe
2025-02-26  5:39     ` Selvin Xavier
2025-02-04  8:21 ` [PATCH rdma-rc 4/4] RDMA/bnxt_re: Fix the statistics for Gen P7 VF Selvin Xavier
2025-02-10  8:40 ` [PATCH rdma-rc 0/4] RDMA/bnxt_re: Bug fixes for 6.14 Leon Romanovsky

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=1738657285-23968-3-git-send-email-selvin.xavier@broadcom.com \
    --to=selvin.xavier@broadcom.com \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=jgg@ziepe.ca \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /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