mirror of
https://github.com/fail0verflow/switch-linux.git
synced 2025-05-04 02:34:21 -04:00
net: aquantia: Fix error handling in aq_pci_probe()
We should check "self->aq_hw" for allocation failure, and also we should
free it on the error paths.
Fixes: 23ee07ad3c
("net: aquantia: Cleanup pci functions module")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ed04c46d4e
commit
370c10522e
1 changed files with 10 additions and 4 deletions
|
@ -226,6 +226,10 @@ static int aq_pci_probe(struct pci_dev *pdev,
|
||||||
goto err_ioremap;
|
goto err_ioremap;
|
||||||
|
|
||||||
self->aq_hw = kzalloc(sizeof(*self->aq_hw), GFP_KERNEL);
|
self->aq_hw = kzalloc(sizeof(*self->aq_hw), GFP_KERNEL);
|
||||||
|
if (!self->aq_hw) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto err_ioremap;
|
||||||
|
}
|
||||||
self->aq_hw->aq_nic_cfg = aq_nic_get_cfg(self);
|
self->aq_hw->aq_nic_cfg = aq_nic_get_cfg(self);
|
||||||
|
|
||||||
for (bar = 0; bar < 4; ++bar) {
|
for (bar = 0; bar < 4; ++bar) {
|
||||||
|
@ -235,19 +239,19 @@ static int aq_pci_probe(struct pci_dev *pdev,
|
||||||
mmio_pa = pci_resource_start(pdev, bar);
|
mmio_pa = pci_resource_start(pdev, bar);
|
||||||
if (mmio_pa == 0U) {
|
if (mmio_pa == 0U) {
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
goto err_ioremap;
|
goto err_free_aq_hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
reg_sz = pci_resource_len(pdev, bar);
|
reg_sz = pci_resource_len(pdev, bar);
|
||||||
if ((reg_sz <= 24 /*ATL_REGS_SIZE*/)) {
|
if ((reg_sz <= 24 /*ATL_REGS_SIZE*/)) {
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
goto err_ioremap;
|
goto err_free_aq_hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->aq_hw->mmio = ioremap_nocache(mmio_pa, reg_sz);
|
self->aq_hw->mmio = ioremap_nocache(mmio_pa, reg_sz);
|
||||||
if (!self->aq_hw->mmio) {
|
if (!self->aq_hw->mmio) {
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
goto err_ioremap;
|
goto err_free_aq_hw;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +259,7 @@ static int aq_pci_probe(struct pci_dev *pdev,
|
||||||
|
|
||||||
if (bar == 4) {
|
if (bar == 4) {
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
goto err_ioremap;
|
goto err_free_aq_hw;
|
||||||
}
|
}
|
||||||
|
|
||||||
numvecs = min((u8)AQ_CFG_VECS_DEF,
|
numvecs = min((u8)AQ_CFG_VECS_DEF,
|
||||||
|
@ -290,6 +294,8 @@ err_register:
|
||||||
aq_pci_free_irq_vectors(self);
|
aq_pci_free_irq_vectors(self);
|
||||||
err_hwinit:
|
err_hwinit:
|
||||||
iounmap(self->aq_hw->mmio);
|
iounmap(self->aq_hw->mmio);
|
||||||
|
err_free_aq_hw:
|
||||||
|
kfree(self->aq_hw);
|
||||||
err_ioremap:
|
err_ioremap:
|
||||||
free_netdev(ndev);
|
free_netdev(ndev);
|
||||||
err_pci_func:
|
err_pci_func:
|
||||||
|
|
Loading…
Add table
Reference in a new issue