Prechádzať zdrojové kódy

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
Anurag Chouhan 8 rokov pred
rodič
commit
ce6a405adf

+ 8 - 1
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;
 }

+ 8 - 3
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);