Commit af61bc1e authored by Keita Suzuki's avatar Keita Suzuki Committed by Martin K. Petersen

scsi: hpsa: Fix memory leak in hpsa_init_one()

When hpsa_scsi_add_host() fails, h->lastlogicals is leaked since it is
missing a free() in the error handler.

Fix this by adding free() when hpsa_scsi_add_host() fails.

Link: https://lore.kernel.org/r/20201027073125.14229-1-keitasuzuki.park@sslab.ics.keio.ac.jpTested-by: default avatarDon Brace <don.brace@microchip.com>
Acked-by: default avatarDon Brace <don.brace@microchip.com>
Signed-off-by: default avatarKeita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent fab09aae
......@@ -8855,7 +8855,7 @@ static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
/* hook into SCSI subsystem */
rc = hpsa_scsi_add_host(h);
if (rc)
goto clean7; /* perf, sg, cmd, irq, shost, pci, lu, aer/h */
goto clean8; /* lastlogicals, perf, sg, cmd, irq, shost, pci, lu, aer/h */
/* Monitor the controller for firmware lockups */
h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL;
......@@ -8870,6 +8870,8 @@ static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
HPSA_EVENT_MONITOR_INTERVAL);
return 0;
clean8: /* lastlogicals, perf, sg, cmd, irq, shost, pci, lu, aer/h */
kfree(h->lastlogicals);
clean7: /* perf, sg, cmd, irq, shost, pci, lu, aer/h */
hpsa_free_performant_mode(h);
h->access.set_intr_mask(h, HPSA_INTR_OFF);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment