From 06fed3587426c4ea61959d907dd7706422df983f Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Fri, 31 Aug 2018 12:19:52 -0700 Subject: [PATCH] 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 --- core/hdd/src/wlan_hdd_debugfs_llstat.c | 29 +++++++++++++------------- core/hdd/src/wlan_hdd_stats.c | 12 ++++------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/core/hdd/src/wlan_hdd_debugfs_llstat.c b/core/hdd/src/wlan_hdd_debugfs_llstat.c index 7db85b6026d1..eb2ebd62b781 100644 --- a/core/hdd/src/wlan_hdd_debugfs_llstat.c +++ b/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; } /** diff --git a/core/hdd/src/wlan_hdd_stats.c b/core/hdd/src/wlan_hdd_stats.c index bc079b3a2aa6..bc04117c8159 100644 --- a/core/hdd/src/wlan_hdd_stats.c +++ b/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; } /**