Commit 1ded56df authored by Dan Carpenter's avatar Dan Carpenter Committed by Bjorn Helgaas

PCI: xgene: Fix double free on init error

The "port" variable was allocated with devm_kzalloc() so if we free it with
kfree() it will be freed twice.  Also I changed it to propogate the error
from devm_ioremap_resource() instead of returning -ENOMEM.

Fixes: c5d46039 ("PCI: Add MCFG quirks for X-Gene host controller")
Also-posted-by: default avatarShawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Acked-by: default avatarTanmay Inamdar <tinamdar@apm.com>
parent 7ce7d89f
...@@ -246,14 +246,11 @@ static int xgene_pcie_ecam_init(struct pci_config_window *cfg, u32 ipversion) ...@@ -246,14 +246,11 @@ static int xgene_pcie_ecam_init(struct pci_config_window *cfg, u32 ipversion)
ret = xgene_get_csr_resource(adev, &csr); ret = xgene_get_csr_resource(adev, &csr);
if (ret) { if (ret) {
dev_err(dev, "can't get CSR resource\n"); dev_err(dev, "can't get CSR resource\n");
kfree(port);
return ret; return ret;
} }
port->csr_base = devm_ioremap_resource(dev, &csr); port->csr_base = devm_ioremap_resource(dev, &csr);
if (IS_ERR(port->csr_base)) { if (IS_ERR(port->csr_base))
kfree(port); return PTR_ERR(port->csr_base);
return -ENOMEM;
}
port->cfg_base = cfg->win; port->cfg_base = cfg->win;
port->version = ipversion; port->version = ipversion;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment