* [PATCH] [v2] ide: pci: Fix memleak in ide_pci_init_two
@ 2020-12-23 10:48 Dinghao Liu
0 siblings, 0 replies; only message in thread
From: Dinghao Liu @ 2020-12-23 10:48 UTC (permalink / raw)
To: dinghao.liu, kjlu; +Cc: David S. Miller, linux-ide, linux-kernel
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>
---
Changelog:
v2: - Refine the error handling on failure of
ide_host_register().
---
drivers/ide/setup-pci.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index fdc8e813170c..14b8a514b51a 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])) {
@@ -598,10 +598,12 @@ 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
- goto out;
+ goto out_free_host;
+
+ return 0;
+out_free_host:
+ ide_host_free(host);
out_free_bars:
i = n_ports / 2;
while (i--)
--
2.17.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-12-23 10:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-23 10:48 [PATCH] [v2] ide: pci: Fix memleak in ide_pci_init_two Dinghao Liu
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).