Wlan: Allow set monitor mode conf and filter only in monitor mode

Even if driver is not loaded in monitor mode, The cmds to set
monitor mode conf and filter is processed and thus the union
pAdapter->sessionCtx, common for AP/STA/monitor mode, is updated
causing memory corruption. These cmds may also end up sending
START monitor mode.

To avoid this allow set monitor mode conf and filter only in
monitor mode.

Change-Id: I5e422776e35164a1875e7e9857debf7f67220b0c
CRs-Fixed: 977282
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index debd6e6..16be32b 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -7714,12 +7714,18 @@
                v_U32_t magic = 0;
                struct completion cmpVar;
                long waitRet = 0;
+               tVOS_CON_MODE mode = hdd_get_conparam();
+
+               if (VOS_MONITOR_MODE != mode) {
+                  hddLog(LOGE, FL("invalid mode %d"), mode);
+                  return -EIO;
+               }
 
                pMonCtx =  WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
                if( pMonCtx == NULL )
                {
                  hddLog(LOGE, "Monitor Context NULL");
-                 break;
+                 return -EIO;
                }
                hddLog(LOG1, "%s: Monitor MOde Configuration: ChNo=%d ChBW=%d CRCCheck=%d type=%d ConversionBit=%d",
                         __func__, apps_args[0], apps_args[1], apps_args[2],
@@ -7750,8 +7756,7 @@
                         VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
                                     FL("failed to post MON MODE REQ"));
                         magic = 0;
-                        ret = -EIO;
-                        break;
+                        return -EIO;
                     }
                     waitRet = wait_for_completion_timeout(&cmpVar,
                                                        MON_MODE_MSG_TIMEOUT);
@@ -7770,12 +7775,18 @@
                v_U32_t magic = 0;
                struct completion cmpVar;
                long waitRet = 0;
+               tVOS_CON_MODE mode = hdd_get_conparam();
+
+               if (VOS_MONITOR_MODE != mode) {
+                  hddLog(LOGE, FL("invalid mode %d"), mode);
+                  return -EIO;
+               }
 
                pMonCtx =  WLAN_HDD_GET_MONITOR_CTX_PTR(pAdapter);
                if( pMonCtx == NULL )
                {
                   hddLog(LOGE, "Monitor Context NULL");
-                  break;
+                  return -EIO;
                }
                /* Input Validation Part of FW */
                pMonCtx->numOfMacFilters=1;
@@ -7800,8 +7811,7 @@
                         VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
                                     FL("failed to post MON MODE REQ"));
                         magic = 0;
-                        ret = -EIO;
-                        break;
+                        return -EIO;
                     }
                     waitRet = wait_for_completion_timeout(&cmpVar,
                                                        MON_MODE_MSG_TIMEOUT);