aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2018-02-22 04:11:55 -0500
committerDavid S. Miller <davem@davemloft.net>2018-02-22 15:33:16 -0500
commit370c10522e96bf1b2e7fd9e906dbe8fb5be895d2 (patch)
tree64513ef921a3a0a9ae871b4e23ef88ad5c07af19
parented04c46d4e70007e102d88dd2ee648008f7f634d (diff)
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: 23ee07ad3c2f ("net: aquantia: Cleanup pci functions module") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
index 22889fc158f2..87c4308b52a7 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
@@ -226,6 +226,10 @@ static int aq_pci_probe(struct pci_dev *pdev,
226 goto err_ioremap; 226 goto err_ioremap;
227 227
228 self->aq_hw = kzalloc(sizeof(*self->aq_hw), GFP_KERNEL); 228 self->aq_hw = kzalloc(sizeof(*self->aq_hw), GFP_KERNEL);
229 if (!self->aq_hw) {
230 err = -ENOMEM;
231 goto err_ioremap;
232 }
229 self->aq_hw->aq_nic_cfg = aq_nic_get_cfg(self); 233 self->aq_hw->aq_nic_cfg = aq_nic_get_cfg(self);
230 234
231 for (bar = 0; bar < 4; ++bar) { 235 for (bar = 0; bar < 4; ++bar) {
@@ -235,19 +239,19 @@ static int aq_pci_probe(struct pci_dev *pdev,
235 mmio_pa = pci_resource_start(pdev, bar); 239 mmio_pa = pci_resource_start(pdev, bar);
236 if (mmio_pa == 0U) { 240 if (mmio_pa == 0U) {
237 err = -EIO; 241 err = -EIO;
238 goto err_ioremap; 242 goto err_free_aq_hw;
239 } 243 }
240 244
241 reg_sz = pci_resource_len(pdev, bar); 245 reg_sz = pci_resource_len(pdev, bar);
242 if ((reg_sz <= 24 /*ATL_REGS_SIZE*/)) { 246 if ((reg_sz <= 24 /*ATL_REGS_SIZE*/)) {
243 err = -EIO; 247 err = -EIO;
244 goto err_ioremap; 248 goto err_free_aq_hw;
245 } 249 }
246 250
247 self->aq_hw->mmio = ioremap_nocache(mmio_pa, reg_sz); 251 self->aq_hw->mmio = ioremap_nocache(mmio_pa, reg_sz);
248 if (!self->aq_hw->mmio) { 252 if (!self->aq_hw->mmio) {
249 err = -EIO; 253 err = -EIO;
250 goto err_ioremap; 254 goto err_free_aq_hw;
251 } 255 }
252 break; 256 break;
253 } 257 }
@@ -255,7 +259,7 @@ static int aq_pci_probe(struct pci_dev *pdev,
255 259
256 if (bar == 4) { 260 if (bar == 4) {
257 err = -EIO; 261 err = -EIO;
258 goto err_ioremap; 262 goto err_free_aq_hw;
259 } 263 }
260 264
261 numvecs = min((u8)AQ_CFG_VECS_DEF, 265 numvecs = min((u8)AQ_CFG_VECS_DEF,
@@ -290,6 +294,8 @@ err_register:
290 aq_pci_free_irq_vectors(self); 294 aq_pci_free_irq_vectors(self);
291err_hwinit: 295err_hwinit:
292 iounmap(self->aq_hw->mmio); 296 iounmap(self->aq_hw->mmio);
297err_free_aq_hw:
298 kfree(self->aq_hw);
293err_ioremap: 299err_ioremap:
294 free_netdev(ndev); 300 free_netdev(ndev);
295err_pci_func: 301err_pci_func: