Skip to content

Commit af61bc1

Browse files
quasi-modmartinkpetersen
authored andcommitted
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.jp Tested-by: Don Brace <don.brace@microchip.com> Acked-by: Don Brace <don.brace@microchip.com> Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent fab09aa commit af61bc1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/scsi/hpsa.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8855,7 +8855,7 @@ static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
88558855
/* hook into SCSI subsystem */
88568856
rc = hpsa_scsi_add_host(h);
88578857
if (rc)
8858-
goto clean7; /* perf, sg, cmd, irq, shost, pci, lu, aer/h */
8858+
goto clean8; /* lastlogicals, perf, sg, cmd, irq, shost, pci, lu, aer/h */
88598859

88608860
/* Monitor the controller for firmware lockups */
88618861
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)
88708870
HPSA_EVENT_MONITOR_INTERVAL);
88718871
return 0;
88728872

8873+
clean8: /* lastlogicals, perf, sg, cmd, irq, shost, pci, lu, aer/h */
8874+
kfree(h->lastlogicals);
88738875
clean7: /* perf, sg, cmd, irq, shost, pci, lu, aer/h */
88748876
hpsa_free_performant_mode(h);
88758877
h->access.set_intr_mask(h, HPSA_INTR_OFF);

0 commit comments

Comments
 (0)