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@xxxxxxxxxx> --- drivers/ide/setup-pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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])) { -- 2.17.1