All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Pylypiv <ipylypiv@google.com>
To: Jack Wang <jinpu.wang@cloud.ionos.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Vishakha Channapattan <vishakhavc@google.com>,
	Changyuan Lyu <changyuanl@google.com>,
	linux-scsi@vger.kernel.org, Igor Pylypiv <ipylypiv@google.com>
Subject: [PATCH 3/4] scsi: pm80xx: Update WARN_ON check in pm8001_mpi_build_cmd()
Date: Mon,  1 Nov 2021 16:28:24 -0700	[thread overview]
Message-ID: <20211101232825.2350233-4-ipylypiv@google.com> (raw)
In-Reply-To: <20211101232825.2350233-1-ipylypiv@google.com>

Starting from commit 05c6c029a44d9 ("scsi: pm80xx: Increase number of
supported queues") driver initializes only max_q_num queues.
Do not use an invalid queue if the WARN_ON condition is true.

Fixes: 7640e1eb8c5de ("scsi: pm80xx: Make mpi_build_cmd locking consistent")
Reviewed-by: Vishakha Channapattan <vishakhavc@google.com>
Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
---
 drivers/scsi/pm8001/pm8001_hwi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index 1a593f2b2c87..3d41f0ac6595 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -1325,7 +1325,9 @@ int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,
 	int q_index = circularQ - pm8001_ha->inbnd_q_tbl;
 	int rv;
 
-	WARN_ON(q_index >= PM8001_MAX_INB_NUM);
+	if (WARN_ON(q_index >= pm8001_ha->max_q_num))
+		return -EINVAL;
+
 	spin_lock_irqsave(&circularQ->iq_lock, flags);
 	rv = pm8001_mpi_msg_free_get(circularQ, pm8001_ha->iomb_size,
 			&pMessage);
-- 
2.33.1.1089.g2158813163f-goog


  parent reply	other threads:[~2021-11-01 23:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 23:28 [PATCH 0/4] small pm80xx cleanups and fixes Igor Pylypiv
2021-11-01 23:28 ` [PATCH 1/4] scsi: pm80xx: Apply byte mask for phy id in mpi_phy_start_resp() Igor Pylypiv
2021-11-02  7:04   ` Jinpu Wang
2021-11-01 23:28 ` [PATCH 2/4] scsi: pm80xx: Do not check the address-of value for NULL Igor Pylypiv
2021-11-02  7:06   ` Jinpu Wang
2021-11-01 23:28 ` Igor Pylypiv [this message]
2021-11-02  7:07   ` [PATCH 3/4] scsi: pm80xx: Update WARN_ON check in pm8001_mpi_build_cmd() Jinpu Wang
2021-11-01 23:28 ` [PATCH 4/4] scsi: pm80xx: Use bitmap_zalloc() for tags bitmap allocation Igor Pylypiv
2021-11-02  7:08   ` Jinpu Wang
2021-11-19  2:50 ` [PATCH 0/4] small pm80xx cleanups and fixes Martin K. Petersen
2021-11-23  3:49 ` Martin K. Petersen

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=20211101232825.2350233-4-ipylypiv@google.com \
    --to=ipylypiv@google.com \
    --cc=changyuanl@google.com \
    --cc=jejb@linux.ibm.com \
    --cc=jinpu.wang@cloud.ionos.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=vishakhavc@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.