scsi: mpi3mr: Fix error handling in mpi3mr_setup_isr()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 9 Jun 2021 09:27:14 +0000 (12:27 +0300)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 10 Jun 2021 03:01:24 +0000 (23:01 -0400)
commit2938bedd0efa0964db563999b9b3b866b2d1a090
tree4fcbb62a0714d2ead7ddbdc50e168cede444bf2b
parentd46bdecd9f3cdf6c5e1beb5975b5dbf098c1a9f7
scsi: mpi3mr: Fix error handling in mpi3mr_setup_isr()

The pci_alloc_irq_vectors_affinity() function returns negative error codes
or it returns a number between the minimum vectors (1 in this case) and
max_vectors.  It won't return zero.  Because "i" is a u16 then the error
handling won't work.  And also if it did work the error code was not set.

Really "max_vectors" can be an int as well because we're doing a min_t() on
int type.  The other change is that it's better to remove unnecessary
initialization so that static checkers can warn us if there are ever
uninitialized variable bugs introduced in the future.

I changed the error code from -1 (-EPERM) if the kmalloc() failed to
-ENOMEM.  And on success path I changed it from "return retval;" to "return
0;" which shouldn't affect the compiled code but makes it more readable.

Link: https://lore.kernel.org/r/YMCJcnmSI4kOIyv/@mwanda
Fixes: 824a156633df ("scsi: mpi3mr: Base driver code")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/mpi3mr/mpi3mr_fw.c