diff options
| author | Dustin Brown <dustinb@codeaurora.org> | 2017-01-12 16:20:31 -0800 |
|---|---|---|
| committer | qcabuildsw <qcabuildsw@localhost> | 2017-01-13 12:27:53 -0800 |
| commit | d807853df37f42fa8e03f68832cf10c7c5c1da95 (patch) | |
| tree | 1b6dd4080a5dbf9f6acfe1b3062eee03a01a4258 | |
| parent | 3333a6a969943addbb83b0ddc3d001f76b7b9ecc (diff) | |
qcacld-3.0: Fix possible NULL dereference in unit-test suspend/resume
Fix 4 possible NULL dereference issues in unit-test suspend/resume
logic, as identified by static analysis.
Change-Id: I605eaf659355c50aeb50d4324db4fb209aa19e70
CRs-Fixed: 1110954
| -rw-r--r-- | core/hdd/src/wlan_hdd_power.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/core/hdd/src/wlan_hdd_power.c b/core/hdd/src/wlan_hdd_power.c index 353bc56ceac1..d31d92f74a60 100644 --- a/core/hdd/src/wlan_hdd_power.c +++ b/core/hdd/src/wlan_hdd_power.c @@ -2478,10 +2478,18 @@ static unsigned long fake_apps_state; static void __hdd_wlan_fake_apps_resume(struct wiphy *wiphy, struct net_device *dev) { - qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); + qdf_device_t qdf_dev; int i, resume_err; hdd_info("Unit-test resume WLAN"); + + qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); + if (!qdf_dev) { + hdd_err("Failed to get QDF device context"); + QDF_BUG(0); + return; + } + if (!test_and_clear_bit(HDD_FA_SUSPENDED_BIT, &fake_apps_state)) { hdd_info("Not unit-test suspended; Nothing to do"); return; @@ -2530,12 +2538,25 @@ static void hdd_wlan_fake_apps_resume_irq_callback(uint32_t val) int hdd_wlan_fake_apps_suspend(struct wiphy *wiphy, struct net_device *dev) { - qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); - struct hif_opaque_softc *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); + qdf_device_t qdf_dev; + struct hif_opaque_softc *hif_ctx; pm_message_t state; int i, resume_err, suspend_err; hdd_info("Unit-test suspend WLAN"); + + qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); + if (!qdf_dev) { + hdd_err("Failed to get QDF device context"); + return -EINVAL; + } + + hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); + if (!hif_ctx) { + hdd_err("Failed to get HIF context"); + return -EINVAL; + } + if (test_and_set_bit(HDD_FA_SUSPENDED_BIT, &fake_apps_state)) { hdd_info("Already unit-test suspended; Nothing to do"); return 0; @@ -2595,7 +2616,13 @@ resume_done: int hdd_wlan_fake_apps_resume(struct wiphy *wiphy, struct net_device *dev) { - struct hif_opaque_softc *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); + struct hif_opaque_softc *hif_ctx; + + hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); + if (!hif_ctx) { + hdd_err("Failed to get HIF context"); + return -EINVAL; + } hif_fake_apps_resume(hif_ctx); __hdd_wlan_fake_apps_resume(wiphy, dev); |
