From: Dinghao Liu <dinghao.liu@zju.edu.cn>
To: dinghao.liu@zju.edu.cn, kjlu@umn.edu
Cc: "David S. Miller" <davem@davemloft.net>,
linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ide: pci: Fix memleak in ide_pci_init_two
Date: Sun, 20 Dec 2020 15:05:40 +0800 [thread overview]
Message-ID: <20201220070541.7515-1-dinghao.liu@zju.edu.cn> (raw)
When do_ide_setup_pci_device() fails, host allocated
by ide_host_alloc() may not have been freed, which
leads to memleak.
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
drivers/ide/setup-pci.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index fdc8e813170c..c7da5368fcd4 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -586,7 +586,7 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
* do_ide_setup_pci_device() on the first device!
*/
if (ret < 0)
- goto out_free_bars;
+ goto out_free_host;
/* fixup IRQ */
if (ide_pci_is_in_compatibility_mode(pdev[i])) {
@@ -597,11 +597,11 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
}
ret = ide_host_register(host, d, hws);
- if (ret)
- ide_host_free(host);
- else
+ if (!ret)
goto out;
+out_free_host:
+ ide_host_free(host);
out_free_bars:
i = n_ports / 2;
while (i--)
--
2.17.1
next reply other threads:[~2020-12-20 7:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-20 7:05 Dinghao Liu [this message]
2020-12-20 19:50 ` [PATCH] ide: pci: Fix memleak in ide_pci_init_two Kari Argillander
2020-12-23 8:59 ` dinghao.liu
-- strict thread matches above, loose matches on Subject: below --
2020-08-26 9:17 Dinghao Liu
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=20201220070541.7515-1-dinghao.liu@zju.edu.cn \
--to=dinghao.liu@zju.edu.cn \
--cc=davem@davemloft.net \
--cc=kjlu@umn.edu \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).