浏览代码

qcacld-3.0: Fix possible NULL hdd context dereference

On dp_aggregation sysfs store or show, wiphy is fetched
from hdd context without validation. This could result
in possible NULL hdd context dereference.

Fix is to validate the hdd context before dereference
to get wiphy.

Change-Id: I0d01f64e95c9aa3f09ccc940a64d5a25148c302e
CRs-Fixed: 2726433
Yeshwanth Sriram Guntuka 4 年之前
父节点
当前提交
59e699aa03
共有 1 个文件被更改,包括 10 次插入10 次删除
  1. 10 10
      core/hdd/src/wlan_hdd_sysfs_dp_aggregation.c

+ 10 - 10
core/hdd/src/wlan_hdd_sysfs_dp_aggregation.c

@@ -47,12 +47,6 @@ static ssize_t
 __hdd_sysfs_dp_aggregation_show(struct hdd_context *hdd_ctx,
 				struct kobj_attribute *attr, char *buf)
 {
-	int ret;
-
-	ret = wlan_hdd_validate_context(hdd_ctx);
-	if (ret != 0)
-		return ret;
-
 	if (!wlan_hdd_validate_modules_state(hdd_ctx))
 		return -EINVAL;
 
@@ -69,6 +63,11 @@ static ssize_t hdd_sysfs_dp_aggregation_show(struct kobject *kobj,
 	struct osif_psoc_sync *psoc_sync;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	ssize_t errno_size;
+	int ret;
+
+	ret = wlan_hdd_validate_context(hdd_ctx);
+	if (ret != 0)
+		return ret;
 
 	errno_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy),
 					     &psoc_sync);
@@ -93,10 +92,6 @@ __hdd_sysfs_dp_aggregation_store(struct hdd_context *hdd_ctx,
 	int ret;
 	ol_txrx_soc_handle dp_soc = cds_get_context(QDF_MODULE_ID_SOC);
 
-	ret = wlan_hdd_validate_context(hdd_ctx);
-	if (ret != 0)
-		return ret;
-
 	if (!wlan_hdd_validate_modules_state(hdd_ctx) || !dp_soc)
 		return -EINVAL;
 
@@ -131,6 +126,11 @@ hdd_sysfs_dp_aggregation_store(struct kobject *kobj,
 	struct osif_psoc_sync *psoc_sync;
 	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	ssize_t errno_size;
+	int ret;
+
+	ret = wlan_hdd_validate_context(hdd_ctx);
+	if (ret != 0)
+		return ret;
 
 	errno_size = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy),
 					     &psoc_sync);