From ce6a405adfee29dd9dbd8dd75b46a382af1836e1 Mon Sep 17 00:00:00 2001 From: Anurag Chouhan Date: Wed, 14 Sep 2016 18:20:42 +0530 Subject: [PATCH] qcacld-3.0: Add check to Validate hif_ctx Currently hif_ctx is passed as a parameter in hif_get_hw_info and hif_bus_reset_resume without any validation check for the parameter. This change Validates hif_ctx before dereferencing the hif_ctx. Change-Id: I17636692863bfdded691594cef40ebe55e262849 CRs-Fixed: 1066838 --- core/hdd/src/wlan_hdd_driver_ops.c | 9 ++++++++- core/hdd/src/wlan_hdd_main.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/hdd/src/wlan_hdd_driver_ops.c b/core/hdd/src/wlan_hdd_driver_ops.c index 68d6e6770f80..299b5d13487c 100644 --- a/core/hdd/src/wlan_hdd_driver_ops.c +++ b/core/hdd/src/wlan_hdd_driver_ops.c @@ -800,9 +800,16 @@ int wlan_hdd_bus_resume_noirq(void) static int wlan_hdd_bus_reset_resume(void) { int ret; + struct hif_opaque_softc *scn = NULL; + + scn = cds_get_context(QDF_MODULE_ID_HIF); + if (!scn) { + hdd_err("Failed to get HIF context"); + return -EFAULT; + } cds_ssr_protect(__func__); - ret = hif_bus_reset_resume(cds_get_context(QDF_MODULE_ID_HIF)); + ret = hif_bus_reset_resume(scn); cds_ssr_unprotect(__func__); return ret; } diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 357114a45e10..a157b5ee20e3 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -7634,6 +7634,10 @@ int hdd_wlan_startup(struct device *dev) } hif_sc = cds_get_context(QDF_MODULE_ID_HIF); + if (!hif_sc) { + hdd_err("HIF context is NULL"); + goto err_close_adapter; + } /* * target hw version/revision would only be retrieved after firmware * donwload @@ -7704,19 +7708,20 @@ int hdd_wlan_startup(struct device *dev) err_debugfs_exit: hdd_debugfs_exit(adapter); + +err_close_adapter: hdd_close_all_adapters(hdd_ctx, false); if (rtnl_held) hdd_release_rtnl_lock(); +err_ipa_cleanup: + hdd_ipa_cleanup(hdd_ctx); err_wiphy_unregister: wiphy_unregister(hdd_ctx->wiphy); wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); -err_ipa_cleanup: - hdd_ipa_cleanup(hdd_ctx); - err_stop_modules: hdd_wlan_stop_modules(hdd_ctx, false);