summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDundi Raviteja <dundi@codeaurora.org>2018-09-24 11:04:31 +0530
committernshrivas <nshrivas@codeaurora.org>2018-10-08 15:26:58 -0700
commitdd7e7f3fda7df3d362e4cb1f867e053bfdfa9da4 (patch)
treed42c739f5f12a6ac7c88808e7c88742cd8e695e6
parentcc949404c251bcf0020e23f38c9174b82dc1e218 (diff)
qcacld-3.0: Validate adapter and free llstats buffer if get request fails
__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. Also __wlan_hdd_open_ll_stats_debugfs() fails to free the llstats buffer in the event that wlan_hdd_ll_stats_get() fails. Ensure the given adapter is up before sending the link layer stats request to firmware and add error handling for this call which frees the newly allocated buffer. Change-Id: Ic5cff77a758ff81da82dd1143d77da68d87b9291 CRs-Fixed: 2304715
-rw-r--r--core/hdd/src/wlan_hdd_debugfs_llstat.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/core/hdd/src/wlan_hdd_debugfs_llstat.c b/core/hdd/src/wlan_hdd_debugfs_llstat.c
index fe2fb4f27bf5..96d2a67d32ca 100644
--- a/core/hdd/src/wlan_hdd_debugfs_llstat.c
+++ b/core/hdd/src/wlan_hdd_debugfs_llstat.c
@@ -424,7 +424,7 @@ static int __wlan_hdd_open_ll_stats_debugfs(struct inode *inode,
{
hdd_adapter_t *adapter;
hdd_context_t *hdd_ctx;
- int ret;
+ int errno;
ENTER();
@@ -432,26 +432,28 @@ static int __wlan_hdd_open_ll_stats_debugfs(struct inode *inode,
file->private_data = inode->i_private;
adapter = (hdd_adapter_t *)file->private_data;
- if ((NULL == 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 (0 != ret)
- return ret;
-
- ret = wlan_hdd_llstats_alloc_buf();
- if (0 != ret)
- return ret;
-
- ret = wlan_hdd_ll_stats_get(adapter, DEBUGFS_LLSTATS_REQID,
- DEBUGFS_LLSTATS_REQMASK);
- if (0 != ret)
- return ret;
+ errno = wlan_hdd_validate_context(hdd_ctx);
+ if (errno)
+ return errno;
+
+ errno = wlan_hdd_llstats_alloc_buf();
+ if (errno)
+ return errno;
+
+ errno = wlan_hdd_ll_stats_get(adapter, DEBUGFS_LLSTATS_REQID,
+ DEBUGFS_LLSTATS_REQMASK);
+ if (errno) {
+ wlan_hdd_llstats_free_buf();
+ return errno;
+ }
EXIT();
+
return 0;
}