aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/pcie/trans.c
diff options
context:
space:
mode:
authorLuciano Coelho <luciano.coelho@intel.com>2013-08-10 09:35:45 -0400
committerJohannes Berg <johannes.berg@intel.com>2013-08-12 09:20:29 -0400
commit6965a3540a4b45ee5b6fa91276a8134e25e17b63 (patch)
treeb82db7e6f1337b1e71d1cdebf2bb930d20a7b33a /drivers/net/wireless/iwlwifi/pcie/trans.c
parentf8f03c3edc39f179457a4a5c6095f45a8300db9b (diff)
iwlwifi: pcie: don't swallow error codes in iwl_trans_pcie_alloc()
The iwl_trans_pcie_alloc() function doesn't pass up error codes returned from functions it calls, swallowing them and returning NULL in all failure cases. The caller checks if the return value is NULL and returns -ENOMEM. This is not correct, because in certain cases the failure was not due to an OOM situation. To fix this, modify the iwl_trans_pcie_alloc() function to use ERR_PTR() to return error codes and clean up the error handling code a bit. Signed-off-by: Luciano Coelho <luciano.coelho@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/pcie/trans.c')
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index d88c0c748274..ff9787fac205 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -1381,9 +1381,10 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
1381 1381
1382 trans = kzalloc(sizeof(struct iwl_trans) + 1382 trans = kzalloc(sizeof(struct iwl_trans) +
1383 sizeof(struct iwl_trans_pcie), GFP_KERNEL); 1383 sizeof(struct iwl_trans_pcie), GFP_KERNEL);
1384 1384 if (!trans) {
1385 if (!trans) 1385 err = -ENOMEM;
1386 return NULL; 1386 goto out;
1387 }
1387 1388
1388 trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1389 trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
1389 1390
@@ -1406,10 +1407,9 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
1406 PCIE_LINK_STATE_CLKPM); 1407 PCIE_LINK_STATE_CLKPM);
1407 } 1408 }
1408 1409
1409 if (pci_enable_device(pdev)) { 1410 err = pci_enable_device(pdev);
1410 err = -ENODEV; 1411 if (err)
1411 goto out_no_pci; 1412 goto out_no_pci;
1412 }
1413 1413
1414 pci_set_master(pdev); 1414 pci_set_master(pdev);
1415 1415
@@ -1478,17 +1478,20 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
1478 SLAB_HWCACHE_ALIGN, 1478 SLAB_HWCACHE_ALIGN,
1479 NULL); 1479 NULL);
1480 1480
1481 if (!trans->dev_cmd_pool) 1481 if (!trans->dev_cmd_pool) {
1482 err = -ENOMEM;
1482 goto out_pci_disable_msi; 1483 goto out_pci_disable_msi;
1484 }
1483 1485
1484 trans_pcie->inta_mask = CSR_INI_SET_MASK; 1486 trans_pcie->inta_mask = CSR_INI_SET_MASK;
1485 1487
1486 if (iwl_pcie_alloc_ict(trans)) 1488 if (iwl_pcie_alloc_ict(trans))
1487 goto out_free_cmd_pool; 1489 goto out_free_cmd_pool;
1488 1490
1489 if (request_threaded_irq(pdev->irq, iwl_pcie_isr_ict, 1491 err = request_threaded_irq(pdev->irq, iwl_pcie_isr_ict,
1490 iwl_pcie_irq_handler, 1492 iwl_pcie_irq_handler,
1491 IRQF_SHARED, DRV_NAME, trans)) { 1493 IRQF_SHARED, DRV_NAME, trans);
1494 if (err) {
1492 IWL_ERR(trans, "Error allocating IRQ %d\n", pdev->irq); 1495 IWL_ERR(trans, "Error allocating IRQ %d\n", pdev->irq);
1493 goto out_free_ict; 1496 goto out_free_ict;
1494 } 1497 }
@@ -1507,5 +1510,6 @@ out_pci_disable_device:
1507 pci_disable_device(pdev); 1510 pci_disable_device(pdev);
1508out_no_pci: 1511out_no_pci:
1509 kfree(trans); 1512 kfree(trans);
1510 return NULL; 1513out:
1514 return ERR_PTR(err);
1511} 1515}