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: c5d4603961
("PCI: Add MCFG quirks for X-Gene host controller")
Also-posted-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Tanmay Inamdar <tinamdar@apm.com>
This commit is contained in:
parent
7ce7d89f48
commit
1ded56df32
|
@ -246,14 +246,11 @@ static int xgene_pcie_ecam_init(struct pci_config_window *cfg, u32 ipversion)
|
|||
ret = xgene_get_csr_resource(adev, &csr);
|
||||
if (ret) {
|
||||
dev_err(dev, "can't get CSR resource\n");
|
||||
kfree(port);
|
||||
return ret;
|
||||
}
|
||||
port->csr_base = devm_ioremap_resource(dev, &csr);
|
||||
if (IS_ERR(port->csr_base)) {
|
||||
kfree(port);
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (IS_ERR(port->csr_base))
|
||||
return PTR_ERR(port->csr_base);
|
||||
|
||||
port->cfg_base = cfg->win;
|
||||
port->version = ipversion;
|
||||
|
|
Loading…
Reference in New Issue