ソースを参照

qcacld-3.0: Add NULL check for QDF_MODULE_ID_HIF context

The context pointer return from the cds_get_context api
for QDF_MODULE_ID_HIF can be NULL.

Add NULL check to avoid hif_ctx pointer dereferencing

CRs-Fixed: 1041960
Change-Id: Ibdcf8809a998ec42cecd5df1cf6884fa81bb9dcb
SaidiReddy Yenuga 8 年 前
コミット
d83236619f
1 ファイル変更18 行追加2 行削除
  1. 18 2
      core/hdd/src/wlan_hdd_driver_ops.c

+ 18 - 2
core/hdd/src/wlan_hdd_driver_ops.c

@@ -363,6 +363,10 @@ static int wlan_hdd_probe(struct device *dev, void *bdev, const hif_bus_id *bid,
 		goto err_epping_close;
 
 	hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
+
+	if (NULL == hif_ctx)
+		goto err_epping_close;
+
 	qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
 
 	status = ol_cds_init(qdf_dev, hif_ctx);
@@ -446,6 +450,9 @@ static void wlan_hdd_remove(struct device *dev)
 
 	hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
 
+	if (NULL == hif_ctx)
+		return;
+
 	hif_disable_power_management(hif_ctx);
 
 	if (QDF_IS_EPPING_ENABLED(cds_get_conparam())) {
@@ -543,7 +550,7 @@ void wlan_hdd_notify_handler(int state)
 static int __wlan_hdd_bus_suspend(pm_message_t state)
 {
 	void *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
+	void *hif_ctx;
 	int err = wlan_hdd_validate_context(hdd_ctx);
 	int status;
 
@@ -552,6 +559,11 @@ static int __wlan_hdd_bus_suspend(pm_message_t state)
 	if (err)
 		goto done;
 
+	hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
+	if (NULL == hif_ctx) {
+		err = -EINVAL;
+		goto done;
+	}
 	err = qdf_status_to_os_return(
 			ol_txrx_bus_suspend());
 	if (err)
@@ -616,12 +628,16 @@ int wlan_hdd_bus_suspend(pm_message_t state)
 static int __wlan_hdd_bus_resume(void)
 {
 	void *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-	void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
+	void *hif_ctx;
 	int status = wlan_hdd_validate_context(hdd_ctx);
 
 	if (status)
 		return status;
 
+	hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
+	if (NULL == hif_ctx)
+		return -EINVAL;
+
 	status = hif_bus_resume(hif_ctx);
 	QDF_BUG(!status);