Skip to content

Commit b2e203d

Browse files
quasi-modgregkh
authored andcommitted
misc: rtsx: Fix memory leak in rtsx_pci_probe
[ Upstream commit bc28369 ] When mfd_add_devices() fail, pcr->slots should also be freed. However, the current implementation does not free the member, leading to a memory leak. Fix this by adding a new goto label that frees pcr->slots. Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp> Link: https://lore.kernel.org/r/20200909071853.4053-1-keitasuzuki.park@sslab.ics.keio.ac.jp Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4e57482 commit b2e203d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/misc/cardreader/rtsx_pcr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,12 +1562,14 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
15621562
ret = mfd_add_devices(&pcidev->dev, pcr->id, rtsx_pcr_cells,
15631563
ARRAY_SIZE(rtsx_pcr_cells), NULL, 0, NULL);
15641564
if (ret < 0)
1565-
goto disable_irq;
1565+
goto free_slots;
15661566

15671567
schedule_delayed_work(&pcr->idle_work, msecs_to_jiffies(200));
15681568

15691569
return 0;
15701570

1571+
free_slots:
1572+
kfree(pcr->slots);
15711573
disable_irq:
15721574
free_irq(pcr->irq, (void *)pcr);
15731575
disable_msi:

0 commit comments

Comments
 (0)