diff --git a/core/hdd/src/wlan_hdd_driver_ops.c b/core/hdd/src/wlan_hdd_driver_ops.c index 76ced7cd94bb..ca792a67db08 100644 --- a/core/hdd/src/wlan_hdd_driver_ops.c +++ b/core/hdd/src/wlan_hdd_driver_ops.c @@ -1042,17 +1042,23 @@ static int __wlan_hdd_bus_suspend(struct wow_enable_params wow_params) hdd_info("starting bus suspend"); hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); + if (!hdd_ctx) { + hdd_err_rl("hdd context is NULL"); + return -ENODEV; + } + + /* If Wifi is off, return success for system suspend */ + if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { + hdd_debug("Driver Module closed; skipping suspend"); + return 0; + } + err = wlan_hdd_validate_context(hdd_ctx); if (err) { hdd_err("Invalid hdd context: %d", err); return err; } - if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { - hdd_debug("Driver Module closed; skipping suspend"); - return 0; - } - hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); if (!hif_ctx) { hdd_err("Failed to get hif context"); @@ -1167,17 +1173,24 @@ int wlan_hdd_bus_suspend_noirq(void) uint32_t pending_events; hdd_debug("start bus_suspend_noirq"); + + if (!hdd_ctx) { + hdd_err_rl("hdd context is NULL"); + return -ENODEV; + } + + /* If Wifi is off, return success for system suspend */ + if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { + hdd_debug("Driver module closed; skip bus-noirq suspend"); + return 0; + } + errno = wlan_hdd_validate_context(hdd_ctx); if (errno) { hdd_err("Invalid HDD context: errno %d", errno); return errno; } - if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { - hdd_debug("Driver module closed; skip bus-noirq suspend"); - return 0; - } - hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); if (!hif_ctx) { hdd_err("hif_ctx is null"); @@ -1245,17 +1258,23 @@ int wlan_hdd_bus_resume(void) hdd_info("starting bus resume"); + if (!hdd_ctx) { + hdd_err_rl("hdd context is NULL"); + return -ENODEV; + } + + /* If Wifi is off, return success for system resume */ + if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { + hdd_debug("Driver Module closed; return success"); + return 0; + } + status = wlan_hdd_validate_context(hdd_ctx); if (status) { hdd_err("Invalid hdd context"); return status; } - if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { - hdd_debug("Driver Module closed; return success"); - return 0; - } - hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); if (!hif_ctx) { hdd_err("Failed to get hif context"); @@ -1335,17 +1354,23 @@ int wlan_hdd_bus_resume_noirq(void) if (cds_is_driver_recovering()) return 0; + if (!hdd_ctx) { + hdd_err_rl("hdd context is NULL"); + return -ENODEV; + } + + /* If Wifi is off, return success for system resume */ + if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { + hdd_debug("Driver Module closed return success"); + return 0; + } + status = wlan_hdd_validate_context(hdd_ctx); if (status) { hdd_err("Invalid HDD context: %d", status); return status; } - if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { - hdd_debug("Driver Module closed return success"); - return 0; - } - hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); if (!hif_ctx) return -EINVAL; diff --git a/core/hdd/src/wlan_hdd_power.c b/core/hdd/src/wlan_hdd_power.c index 65034a212f0c..c54eb118fb2f 100644 --- a/core/hdd/src/wlan_hdd_power.c +++ b/core/hdd/src/wlan_hdd_power.c @@ -1896,15 +1896,21 @@ static int _wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) struct hdd_context *hdd_ctx = wiphy_priv(wiphy); int errno; - errno = wlan_hdd_validate_context(hdd_ctx); - if (errno) - return errno; + if (!hdd_ctx) { + hdd_err_rl("hdd context is null"); + return -ENODEV; + } + /* If Wifi is off, return success for system resume */ if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { hdd_debug("Driver Modules not Enabled "); return 0; } + errno = wlan_hdd_validate_context(hdd_ctx); + if (errno) + return errno; + hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); if (!hif_ctx) return -EINVAL; @@ -2152,15 +2158,21 @@ static int _wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, struct hdd_context *hdd_ctx = wiphy_priv(wiphy); int errno; - errno = wlan_hdd_validate_context(hdd_ctx); - if (errno) - return errno; + if (!hdd_ctx) { + hdd_err_rl("hdd context is null"); + return -ENODEV; + } + /* If Wifi is off, return success for system suspend */ if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { hdd_debug("Driver Modules not Enabled "); return 0; } + errno = wlan_hdd_validate_context(hdd_ctx); + if (errno) + return errno; + hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); if (!hif_ctx) return -EINVAL;