Skip to content

Commit ac2df91

Browse files
Karan Kumarjohnmeneghini
authored andcommitted
scsi: fnic: Test for memory allocation failure and return error code
JIRA: https://issues.redhat.com/browse/RHEL-72902 Fix kernel test robot warning. Test for memory allocation failure, and free memory for queues allocated in a multiqueue and non-multiqueue scenario. Return appropriate error code. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/r/202412312347.FE4ZgEoM-lkp@intel.com/ Reported-by: Julia Lawall <julia.lawall@inria.fr> Closes: https://lore.kernel.org/r/202412312347.FE4ZgEoM-lkp@intel.com/ Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com> Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com> Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com> Reviewed-by: Arun Easi <aeasi@cisco.com> Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com> Link: https://lore.kernel.org/r/20250110091924.17729-1-kartilak@cisco.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> (cherry picked from commit 5442867) Signed-off-by: Karan Kumar <karkumar@redhat.com>
1 parent 6176e38 commit ac2df91

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

drivers/scsi/fnic/fnic_main.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,14 @@ static void fnic_scsi_init(struct fnic *fnic)
581581
host->transportt = fnic_fc_transport;
582582
}
583583

584+
static void fnic_free_ioreq_tables_mq(struct fnic *fnic)
585+
{
586+
int hwq;
587+
588+
for (hwq = 0; hwq < fnic->wq_copy_count; hwq++)
589+
kfree(fnic->sw_copy_wq[hwq].io_req_table);
590+
}
591+
584592
static int fnic_scsi_drv_init(struct fnic *fnic)
585593
{
586594
struct Scsi_Host *host = fnic->host;
@@ -613,6 +621,11 @@ static int fnic_scsi_drv_init(struct fnic *fnic)
613621
fnic->sw_copy_wq[hwq].io_req_table =
614622
kzalloc((fnic->sw_copy_wq[hwq].ioreq_table_size + 1) *
615623
sizeof(struct fnic_io_req *), GFP_KERNEL);
624+
625+
if (!fnic->sw_copy_wq[hwq].io_req_table) {
626+
fnic_free_ioreq_tables_mq(fnic);
627+
return -ENOMEM;
628+
}
616629
}
617630

618631
dev_info(&fnic->pdev->dev, "fnic copy wqs: %d, Q0 ioreq table size: %d\n",
@@ -1059,6 +1072,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
10591072

10601073
err_out_free_stats_debugfs:
10611074
fnic_stats_debugfs_remove(fnic);
1075+
fnic_free_ioreq_tables_mq(fnic);
10621076
scsi_remove_host(fnic->host);
10631077
err_out_scsi_drv_init:
10641078
fnic_free_intr(fnic);

0 commit comments

Comments
 (0)