Jelajahi Sumber

qcacld-3.0: Validate link layer stats adapter

__wlan_hdd_open_ll_stats_debugfs() currently does not ensure the given
adapter is up. This can lead to sending an invalid vdev Id to firmware.
Ensure the given adapter is up before sending the link layer stats
request to firmware.

Change-Id: I1c81f56ec795bc782404293c0f4abd8bbeb6b124
CRs-Fixed: 2306604
Dustin Brown 6 tahun lalu
induk
melakukan
06fed35874
2 mengubah file dengan 18 tambahan dan 23 penghapusan
  1. 14 15
      core/hdd/src/wlan_hdd_debugfs_llstat.c
  2. 4 8
      core/hdd/src/wlan_hdd_stats.c

+ 14 - 15
core/hdd/src/wlan_hdd_debugfs_llstat.c

@@ -428,7 +428,7 @@ static int __wlan_hdd_open_ll_stats_debugfs(struct inode *inode,
 {
 	struct hdd_adapter *adapter;
 	struct hdd_context *hdd_ctx;
-	int ret;
+	int errno;
 
 	hdd_enter();
 
@@ -436,23 +436,22 @@ static int __wlan_hdd_open_ll_stats_debugfs(struct inode *inode,
 		file->private_data = inode->i_private;
 
 	adapter = (struct hdd_adapter *)file->private_data;
-	if (!adapter || WLAN_HDD_ADAPTER_MAGIC != adapter->magic) {
-		hdd_err("Invalid adapter or adapter has invalid magic");
-		return -EINVAL;
-	}
+	errno = hdd_validate_adapter(adapter);
+	if (errno)
+		return errno;
 
 	hdd_ctx = WLAN_HDD_GET_CTX(adapter);
-	ret = wlan_hdd_validate_context(hdd_ctx);
-	if (ret)
-		return ret;
+	errno = wlan_hdd_validate_context(hdd_ctx);
+	if (errno)
+		return errno;
 
-	ret = wlan_hdd_llstats_alloc_buf();
-	if (ret)
-		return ret;
+	errno = wlan_hdd_llstats_alloc_buf();
+	if (errno)
+		return errno;
 
-	ret = wlan_hdd_ll_stats_get(adapter, DEBUGFS_LLSTATS_REQID,
-				    DEBUGFS_LLSTATS_REQMASK);
-	if (ret)
+	errno = wlan_hdd_ll_stats_get(adapter, DEBUGFS_LLSTATS_REQID,
+				      DEBUGFS_LLSTATS_REQMASK);
+	if (errno)
 		goto free_buf;
 
 	hdd_exit();
@@ -464,7 +463,7 @@ free_buf:
 
 	hdd_exit();
 
-	return ret;
+	return errno;
 }
 
 /**

+ 4 - 8
core/hdd/src/wlan_hdd_stats.c

@@ -1407,7 +1407,7 @@ exit:
 int wlan_hdd_ll_stats_get(struct hdd_adapter *adapter, uint32_t req_id,
 			  uint32_t req_mask)
 {
-	int ret;
+	int errno;
 	tSirLLStatsGetReq get_req;
 	struct hdd_station_ctx *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
 	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
@@ -1419,10 +1419,6 @@ int wlan_hdd_ll_stats_get(struct hdd_adapter *adapter, uint32_t req_id,
 		return -EPERM;
 	}
 
-	ret = wlan_hdd_validate_context(hdd_ctx);
-	if (0 != ret)
-		return -EINVAL;
-
 	if (hddstactx->hdd_reassoc_scenario) {
 		hdd_err("Roaming in progress, cannot process the request");
 		return -EBUSY;
@@ -1438,15 +1434,15 @@ int wlan_hdd_ll_stats_get(struct hdd_adapter *adapter, uint32_t req_id,
 	get_req.staId = adapter->session_id;
 
 	rtnl_lock();
-	ret = wlan_hdd_send_ll_stats_req(hdd_ctx, &get_req);
+	errno = wlan_hdd_send_ll_stats_req(hdd_ctx, &get_req);
 	rtnl_unlock();
-	if (0 != ret)
+	if (errno)
 		hdd_err("Send LL stats req failed, id:%u, mask:%d, session:%d",
 			req_id, req_mask, adapter->session_id);
 
 	hdd_exit();
-	return ret;
 
+	return errno;
 }
 
 /**