From dd7e7f3fda7df3d362e4cb1f867e053bfdfa9da4 Mon Sep 17 00:00:00 2001 From: Dundi Raviteja Date: Mon, 24 Sep 2018 11:04:31 +0530 Subject: 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 --- core/hdd/src/wlan_hdd_debugfs_llstat.c | 36 ++++++++++++++++++---------------- 1 file 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; } -- cgit v1.2.3