prima: check for NULL pointer before accessing roc context

Bug: 20500889

Remain on channel context can be NULL in __wlan_hdd_mgmt_tx if
roc is not running already. So check for NULL before accessing
the roc context.

Change-Id: If1f7a1cf6b372882a078f54d0615d5a9bf7dc3ca
Signed-off-by: Bulbul Dabi <bdabi@codeaurora.org>
diff --git a/drivers/staging/prima/CORE/HDD/src/wlan_hdd_p2p.c b/drivers/staging/prima/CORE/HDD/src/wlan_hdd_p2p.c
index b3dc8d6..2a40d72 100644
--- a/drivers/staging/prima/CORE/HDD/src/wlan_hdd_p2p.c
+++ b/drivers/staging/prima/CORE/HDD/src/wlan_hdd_p2p.c
@@ -1132,13 +1132,15 @@
     //then set the wait to 200 ms
     if (offchan && !wait)
     {
-        tANI_U32 current_time = vos_timer_get_system_time();
-        int remaining_roc_time = ((int) cfgState->remain_on_chan_ctx->duration -
-                                 (current_time - pAdapter->startRocTs));
-        if ( remaining_roc_time > ACTION_FRAME_DEFAULT_WAIT)
-            wait = remaining_roc_time;
-        else
-            wait = ACTION_FRAME_DEFAULT_WAIT;
+        wait = ACTION_FRAME_DEFAULT_WAIT;
+        if (pRemainChanCtx)
+        {
+            tANI_U32 current_time = vos_timer_get_system_time();
+            int remaining_roc_time = ((int) pRemainChanCtx->duration -
+                    (current_time - pAdapter->startRocTs));
+            if ( remaining_roc_time > ACTION_FRAME_DEFAULT_WAIT)
+                wait = remaining_roc_time;
+        }
     }
 
     //Call sme API to send out a action frame.