Skip to content

Commit

Permalink
scsi: mpi3mr: Correct a test in mpi3mr_sas_port_add()
Browse files Browse the repository at this point in the history
The test for a possible shift overflow is not correct. Fix it by replacing
the '>' with a '>='.

Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Link: https://lore.kernel.org/r/20240627074827.13672-1-thenzl@redhat.com
Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Tomas Henzl authored and Martin K. Petersen committed Jul 5, 2024
1 parent 06b91c0 commit de24085
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/scsi/mpi3mr/mpi3mr_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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 %lu\n",
i, sizeof(mr_sas_port->phy_mask) * 8);
goto out_fail;
Expand Down

0 comments on commit de24085

Please sign in to comment.