Merge "Check for monitor_conn existence before accessing the same"
diff --git a/wifi/wifi.c b/wifi/wifi.c
index 292089e..c61ef94 100644
--- a/wifi/wifi.c
+++ b/wifi/wifi.c
@@ -617,9 +617,14 @@
 int wifi_ctrl_recv(char *reply, size_t *reply_len)
 {
     int res;
-    int ctrlfd = wpa_ctrl_get_fd(monitor_conn);
+    int ctrlfd;
     struct pollfd rfds[2];
 
+    if (monitor_conn == NULL) {
+        ALOGE("%s: monitor_conn is NULL\n", __func__);
+        return -2;
+    }
+    ctrlfd = wpa_ctrl_get_fd(monitor_conn);
     memset(rfds, 0, 2 * sizeof(struct pollfd));
     rfds[0].fd = ctrlfd;
     rfds[0].events |= POLLIN;