Commit eafe25e0 authored by Luciano Coelho's avatar Luciano Coelho Committed by Johannes Berg

iwlwifi: return -ENOMEM instead of NULL when OOM in iwl_drv_start()

The callers of iwl_drv_start() are probe functions.  If a probe
function returns 0, it means it succeeded.  So if NULL was returned by
iwl_drv_start(), it would be considered as a success.

Fix this by returning -ENOMEM if the driver struct allocation fails in
iwl_drv_start().
Signed-off-by: default avatarLuciano Coelho <luciano.coelho@intel.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 3b1995ad
...@@ -1032,8 +1032,10 @@ struct iwl_drv *iwl_drv_start(struct iwl_trans *trans, ...@@ -1032,8 +1032,10 @@ struct iwl_drv *iwl_drv_start(struct iwl_trans *trans,
int ret; int ret;
drv = kzalloc(sizeof(*drv), GFP_KERNEL); drv = kzalloc(sizeof(*drv), GFP_KERNEL);
if (!drv) if (!drv) {
return NULL; ret = -ENOMEM;
goto err;
}
drv->trans = trans; drv->trans = trans;
drv->dev = trans->dev; drv->dev = trans->dev;
...@@ -1078,7 +1080,7 @@ struct iwl_drv *iwl_drv_start(struct iwl_trans *trans, ...@@ -1078,7 +1080,7 @@ struct iwl_drv *iwl_drv_start(struct iwl_trans *trans,
err_free_drv: err_free_drv:
#endif #endif
kfree(drv); kfree(drv);
err:
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
...@@ -332,7 +332,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -332,7 +332,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
trans_pcie = IWL_TRANS_GET_PCIE_TRANS(iwl_trans); trans_pcie = IWL_TRANS_GET_PCIE_TRANS(iwl_trans);
trans_pcie->drv = iwl_drv_start(iwl_trans, cfg); trans_pcie->drv = iwl_drv_start(iwl_trans, cfg);
if (IS_ERR_OR_NULL(trans_pcie->drv)) { if (IS_ERR(trans_pcie->drv)) {
ret = PTR_ERR(trans_pcie->drv); ret = PTR_ERR(trans_pcie->drv);
goto out_free_trans; goto out_free_trans;
} }
......
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