From: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
To: unlisted-recipients:; (no To-header on input)
Cc: keitasuzuki.park@sslab.ics.keio.ac.jp,
takafumi@sslab.ics.keio.ac.jp, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Vaibhav Gupta <vaibhavgupta40@gmail.com>,
Klaus Doth <kdlnx@doth.eu>, Rui Feng <rui_feng@realsil.com.cn>,
Ricky Wu <ricky_wu@realtek.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] misc: rtsx: Fix memory leak in rtsx_pci_probe
Date: Wed, 9 Sep 2020 07:18:51 +0000 [thread overview]
Message-ID: <20200909071853.4053-1-keitasuzuki.park@sslab.ics.keio.ac.jp> (raw)
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>
---
drivers/misc/cardreader/rtsx_pcr.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/rtsx_pcr.c
index 37ccc67f4914..f2b2805942f5 100644
--- a/drivers/misc/cardreader/rtsx_pcr.c
+++ b/drivers/misc/cardreader/rtsx_pcr.c
@@ -1562,12 +1562,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:
--
2.17.1
reply other threads:[~2020-09-09 7:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200909071853.4053-1-keitasuzuki.park@sslab.ics.keio.ac.jp \
--to=keitasuzuki.park@sslab.ics.keio.ac.jp \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=kdlnx@doth.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=ricky_wu@realtek.com \
--cc=rui_feng@realsil.com.cn \
--cc=takafumi@sslab.ics.keio.ac.jp \
--cc=vaibhavgupta40@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.