Skip to contentSkip to conversation

mpi3mr: correct a test in mpi3mr_sas_port_add

PATCH Applied Tomas Henzl 2 participants 2 messages Jun 27, 2024 – Jul 5, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mpi3mr: correct a test in mpi3mr_sas_port_add

The test for a possible shift overflow is not correct. Fix it by replacing the '>' with a '>='.

---
 drivers/scsi/mpi3mr/mpi3mr_transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_transport.c +2 -2
index 82aa4e418c5a..a454276fcc4c 100644
@@ -1353,7 +1353,7 @@ static struct mpi3mr_sas_port *mpi3mr_sas_port_add(struct mpi3mr_ioc *mrioc,
 	mpi3mr_sas_port_sanity_check(mrioc, mr_sas_node,
 	    mr_sas_port->remote_identify.sas_address, hba_port);
 
-	if (mr_sas_node->num_phys > sizeof(mr_sas_port->phy_mask) * 8)
+	if (mr_sas_node->num_phys >= sizeof(mr_sas_port->phy_mask) * 8)
 		ioc_info(mrioc, "max port count %u could be too high\n",
 		    mr_sas_node->num_phys);
 
@@ -1363,7 +1363,7 @@ static struct mpi3mr_sas_port *mpi3mr_sas_port_add(struct mpi3mr_ioc *mrioc,
 		    (mr_sas_node->phy[i].hba_port != hba_port))
 			continue;
 
-		if (i > sizeof(mr_sas_port->phy_mask) * 8) {
+		if (i >= sizeof(mr_sas_port->phy_mask) * 8) {
 			ioc_warn(mrioc, "skipping port %u, max allowed value is %zu\n",
 			    i, sizeof(mr_sas_port->phy_mask) * 8);
 			goto out_fail;
Signature · 1 line
2.45.2
#1 lore raw

Tomas,

Quoted 2 lines

The test for a possible shift overflow is not correct. Fix it by replacing the '>' with a '>='.

Applied to 6.11/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering