diff mbox series

ide: pci: Fix memleak in ide_pci_init_two

Message ID 20200826091733.924-1-dinghao.liu@zju.edu.cn
State Under Review
Delegated to: David Miller
Headers show
Series ide: pci: Fix memleak in ide_pci_init_two | expand

Commit Message

Dinghao Liu Aug. 26, 2020, 9:17 a.m. UTC
When do_ide_setup_pci_device() fails, host should be
freed just like when ide_host_register() fails.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/ide/setup-pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index fdc8e813170c..e6cba7e24c39 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -585,8 +585,10 @@  int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
 		 * FIXME: Mom, mom, they stole me the helper function to undo
 		 * do_ide_setup_pci_device() on the first device!
 		 */
-		if (ret < 0)
+		if (ret < 0) {
+			ide_host_free(host);
 			goto out_free_bars;
+		}
 
 		/* fixup IRQ */
 		if (ide_pci_is_in_compatibility_mode(pdev[i])) {