[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250110091924.17729-1-kartilak@cisco.com>
Date: Fri, 10 Jan 2025 01:19:24 -0800
From: Karan Tilak Kumar <kartilak@...co.com>
To: sebaddel@...co.com
Cc: arulponn@...co.com,
djhawar@...co.com,
gcboffa@...co.com,
mkai2@...co.com,
satishkh@...co.com,
aeasi@...co.com,
jejb@...ux.ibm.com,
martin.petersen@...cle.com,
linux-scsi@...r.kernel.org,
linux-kernel@...r.kernel.org,
Karan Tilak Kumar <kartilak@...co.com>,
kernel test robot <lkp@...el.com>,
Julia Lawall <julia.lawall@...ia.fr>
Subject: [PATCH] scsi: fnic: Test for memory allocation failure and return error code
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@...el.com>
Closes: https://lore.kernel.org/r/202412312347.FE4ZgEoM-lkp@intel.com/
Reported-by: Julia Lawall <julia.lawall@...ia.fr>
Closes: https://lore.kernel.org/r/202412312347.FE4ZgEoM-lkp@intel.com/
Reviewed-by: Sesidhar Baddela <sebaddel@...co.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@...co.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@...co.com>
Reviewed-by: Arun Easi <aeasi@...co.com>
Signed-off-by: Karan Tilak Kumar <kartilak@...co.com>
---
drivers/scsi/fnic/fnic_main.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index 6eb551112170..6880b40507aa 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -582,6 +582,14 @@ static void fnic_scsi_init(struct fnic *fnic)
host->transportt = fnic_fc_transport;
}
+static void fnic_free_ioreq_tables_mq(struct fnic *fnic)
+{
+ int hwq;
+
+ for (hwq = 0; hwq < fnic->wq_copy_count; hwq++)
+ kfree(fnic->sw_copy_wq[hwq].io_req_table);
+}
+
static int fnic_scsi_drv_init(struct fnic *fnic)
{
struct Scsi_Host *host = fnic->host;
@@ -614,6 +622,11 @@ static int fnic_scsi_drv_init(struct fnic *fnic)
fnic->sw_copy_wq[hwq].io_req_table =
kzalloc((fnic->sw_copy_wq[hwq].ioreq_table_size + 1) *
sizeof(struct fnic_io_req *), GFP_KERNEL);
+
+ if (!fnic->sw_copy_wq[hwq].io_req_table) {
+ fnic_free_ioreq_tables_mq(fnic);
+ return -ENOMEM;
+ }
}
dev_info(&fnic->pdev->dev, "fnic copy wqs: %d, Q0 ioreq table size: %d\n",
@@ -1060,6 +1073,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
err_out_free_stats_debugfs:
fnic_stats_debugfs_remove(fnic);
+ fnic_free_ioreq_tables_mq(fnic);
scsi_remove_host(fnic->host);
err_out_scsi_drv_init:
fnic_free_intr(fnic);
--
2.47.1
Powered by blists - more mailing lists