Skip to content

Commit

Permalink
misc: rtsx: Fix memory leak in rtsx_pci_probe
Browse files Browse the repository at this point in the history
[ 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>
  • Loading branch information
quasi-mod authored and gregkh committed Oct 29, 2020
1 parent 3a8d86d commit 0e3f41b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/misc/cardreader/rtsx_pcr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1534,12 +1534,14 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
ret = mfd_add_devices(&pcidev->dev, pcr->id, rtsx_pcr_cells,
ARRAY_SIZE(rtsx_pcr_cells), NULL, 0, NULL);
if (ret < 0)
goto disable_irq;
goto free_slots;

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

return 0;

free_slots:
kfree(pcr->slots);
disable_irq:
free_irq(pcr->irq, (void *)pcr);
disable_msi:
Expand Down

0 comments on commit 0e3f41b

Please sign in to comment.