Explorar o código

qcacmn: Define wlan_logging event flags as qdf_bitmap

Currently, wlan_logging event flags is defined as unsigned long
and kernel APIs(set_bit/test_bit/clear_bit) are used to operate
on this. But these APIs might expect an unsigned long array and
static analyzer tool reported the same as OOB access on this.
Use QDF APIs to define the bitmap and to operate on the bitmap
also which takes care of these.

Change-Id: Ied1c5cbfc82dc0185c79278bdaedfbd894527ef9
CRs-Fixed: 3865946
Srinivas Dasari hai 8 meses
pai
achega
f32ad32109
Modificáronse 1 ficheiros con 57 adicións e 59 borrados
  1. 57 59
      utils/logging/src/wlan_logging_sock_svc.c

+ 57 - 59
utils/logging/src/wlan_logging_sock_svc.c

@@ -124,7 +124,8 @@
 #define HOST_LOG_FW_FLUSH_COMPLETE       0x003
 #define HOST_LOG_DRIVER_CONNECTIVITY_MSG 0x004
 #define HOST_LOG_CHIPSET_STATS           0x005
-#define FW_LOG_CHIPSET_STATS            0x006
+#define FW_LOG_CHIPSET_STATS             0x006
+#define WLAN_LOGGING_BITS_MAX            7
 
 #define DIAG_TYPE_LOGS                 1
 #define PTT_MSG_DIAG_CMDS_TYPE    0x5050
@@ -207,7 +208,7 @@ struct wlan_logging {
 	/* current logbuf to which the log will be filled to */
 	struct log_msg *pcur_node;
 	/* Event flag used for wakeup and post indication*/
-	unsigned long eventFlag;
+	qdf_bitmap(event_flag, WLAN_LOGGING_BITS_MAX);
 	/* Indicates logger thread is activated */
 	bool is_active;
 	/* Flush completion check */
@@ -481,7 +482,7 @@ int wlan_log_to_user(QDF_TRACE_LEVEL log_level, char *to_be_sent, int length)
 
 	/* Wakeup logger thread */
 	if (wake_up_thread) {
-		set_bit(HOST_LOG_DRIVER_MSG, &gwlan_logging.eventFlag);
+		qdf_set_bit(HOST_LOG_DRIVER_MSG, gwlan_logging.event_flag);
 		wake_up_interruptible(&gwlan_logging.wait_queue);
 	}
 
@@ -895,21 +896,16 @@ static int wlan_logging_thread(void *Arg)
 		setup_flush_timer();
 		ret_wait_status =
 			wait_event_interruptible(gwlan_logging.wait_queue,
-						 (!list_empty
-							  (&gwlan_logging.filled_list)
-						  || test_bit(
-						     HOST_LOG_DRIVER_MSG,
-						     &gwlan_logging.eventFlag)
-						  || test_bit(
-						     HOST_LOG_PER_PKT_STATS,
-						     &gwlan_logging.eventFlag)
-						  || test_bit(
-						     HOST_LOG_FW_FLUSH_COMPLETE,
-						     &gwlan_logging.eventFlag)
-						  || test_bit(
-						     HOST_LOG_DRIVER_CONNECTIVITY_MSG,
-						     &gwlan_logging.eventFlag)
-						  || gwlan_logging.exit));
+				(!list_empty(&gwlan_logging.filled_list) ||
+				 qdf_test_bit(HOST_LOG_DRIVER_MSG,
+					      gwlan_logging.event_flag) ||
+				 qdf_test_bit(HOST_LOG_PER_PKT_STATS,
+					      gwlan_logging.event_flag) ||
+				 qdf_test_bit(HOST_LOG_FW_FLUSH_COMPLETE,
+					      gwlan_logging.event_flag) ||
+				 qdf_test_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG,
+					      gwlan_logging.event_flag) ||
+				 gwlan_logging.exit));
 
 		if (ret_wait_status == -ERESTARTSYS) {
 			qdf_err("wait_event_interruptible returned -ERESTARTSYS");
@@ -920,8 +916,8 @@ static int wlan_logging_thread(void *Arg)
 			break;
 
 
-		if (test_and_clear_bit(HOST_LOG_DRIVER_MSG,
-					&gwlan_logging.eventFlag)) {
+		if (qdf_test_and_clear_bit(HOST_LOG_DRIVER_MSG,
+					   gwlan_logging.event_flag)) {
 			ret = send_filled_buffers_to_user();
 			if (-ENOMEM == ret)
 				msleep(200);
@@ -934,18 +930,18 @@ static int wlan_logging_thread(void *Arg)
 #endif
 		}
 
-		if (test_and_clear_bit(HOST_LOG_PER_PKT_STATS,
-					&gwlan_logging.eventFlag)) {
+		if (qdf_test_and_clear_bit(HOST_LOG_PER_PKT_STATS,
+					   gwlan_logging.event_flag)) {
 			ret = pktlog_send_per_pkt_stats_to_user();
 			if (-ENOMEM == ret)
 				msleep(200);
 		}
 
-		if (test_bit(HOST_LOG_CHIPSET_STATS,
-			     &gwlan_logging.eventFlag) &&
+		if (qdf_test_bit(HOST_LOG_CHIPSET_STATS,
+				 gwlan_logging.event_flag) &&
 		    gwlan_logging.is_flush_complete) {
-			test_and_clear_bit(HOST_LOG_CHIPSET_STATS,
-					   &gwlan_logging.eventFlag);
+			qdf_test_and_clear_bit(HOST_LOG_CHIPSET_STATS,
+					       gwlan_logging.event_flag);
 			ret = wlan_logging_cstats_send_host_buf_to_usr();
 			if (-ENOMEM == ret) {
 				QDF_TRACE_ERROR(QDF_MODULE_ID_QDF,
@@ -954,11 +950,11 @@ static int wlan_logging_thread(void *Arg)
 			}
 		}
 
-		if (test_bit(FW_LOG_CHIPSET_STATS,
-			     &gwlan_logging.eventFlag) &&
+		if (qdf_test_bit(FW_LOG_CHIPSET_STATS,
+				 gwlan_logging.event_flag) &&
 		    gwlan_logging.is_flush_complete) {
-			test_and_clear_bit(FW_LOG_CHIPSET_STATS,
-					   &gwlan_logging.eventFlag);
+			qdf_test_and_clear_bit(FW_LOG_CHIPSET_STATS,
+					       gwlan_logging.event_flag);
 			ret = wlan_logging_cstats_send_fw_buf_to_usr();
 			if (-ENOMEM == ret) {
 				QDF_TRACE_ERROR(QDF_MODULE_ID_QDF,
@@ -967,8 +963,8 @@ static int wlan_logging_thread(void *Arg)
 			}
 		}
 
-		if (test_and_clear_bit(HOST_LOG_FW_FLUSH_COMPLETE,
-					&gwlan_logging.eventFlag)) {
+		if (qdf_test_and_clear_bit(HOST_LOG_FW_FLUSH_COMPLETE,
+					   gwlan_logging.event_flag)) {
 			/* Flush bit could have been set while we were mid
 			 * way in the logging thread. So, need to check other
 			 * buffers like log messages, per packet stats again
@@ -989,12 +985,12 @@ static int wlan_logging_thread(void *Arg)
 				wlan_queue_logmsg_for_app();
 				spin_unlock_irqrestore(&gwlan_logging.spin_lock,
 					flags);
-				set_bit(HOST_LOG_DRIVER_MSG,
-						&gwlan_logging.eventFlag);
-				set_bit(HOST_LOG_PER_PKT_STATS,
-						&gwlan_logging.eventFlag);
-				set_bit(HOST_LOG_FW_FLUSH_COMPLETE,
-						&gwlan_logging.eventFlag);
+				qdf_set_bit(HOST_LOG_DRIVER_MSG,
+					    gwlan_logging.event_flag);
+				qdf_set_bit(HOST_LOG_PER_PKT_STATS,
+					    gwlan_logging.event_flag);
+				qdf_set_bit(HOST_LOG_FW_FLUSH_COMPLETE,
+					    gwlan_logging.event_flag);
 				wake_up_interruptible(
 						&gwlan_logging.wait_queue);
 			}
@@ -1002,8 +998,8 @@ static int wlan_logging_thread(void *Arg)
 
 		/* Dequeue the connectivity_log */
 		wlan_logging_send_connectivity_event();
-		clear_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG,
-			  &gwlan_logging.eventFlag);
+		qdf_clear_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG,
+			      gwlan_logging.event_flag);
 	}
 
 	gwlan_logging.exit_ts = qdf_get_log_timestamp();
@@ -1276,12 +1272,13 @@ int wlan_logging_sock_init_svc(void)
 
 	init_waitqueue_head(&gwlan_logging.wait_queue);
 	gwlan_logging.exit = false;
-	clear_bit(HOST_LOG_DRIVER_MSG, &gwlan_logging.eventFlag);
-	clear_bit(HOST_LOG_PER_PKT_STATS, &gwlan_logging.eventFlag);
-	clear_bit(HOST_LOG_FW_FLUSH_COMPLETE, &gwlan_logging.eventFlag);
-	clear_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG, &gwlan_logging.eventFlag);
-	clear_bit(HOST_LOG_CHIPSET_STATS, &gwlan_logging.eventFlag);
-	clear_bit(FW_LOG_CHIPSET_STATS, &gwlan_logging.eventFlag);
+	qdf_clear_bit(HOST_LOG_DRIVER_MSG, gwlan_logging.event_flag);
+	qdf_clear_bit(HOST_LOG_PER_PKT_STATS, gwlan_logging.event_flag);
+	qdf_clear_bit(HOST_LOG_FW_FLUSH_COMPLETE, gwlan_logging.event_flag);
+	qdf_clear_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG,
+		      gwlan_logging.event_flag);
+	qdf_clear_bit(HOST_LOG_CHIPSET_STATS, gwlan_logging.event_flag);
+	qdf_clear_bit(FW_LOG_CHIPSET_STATS, gwlan_logging.event_flag);
 
 	init_completion(&gwlan_logging.shutdown_comp);
 	gwlan_logging.thread = kthread_create(wlan_logging_thread, NULL,
@@ -1347,12 +1344,13 @@ int wlan_logging_sock_deinit_svc(void)
 	cds_set_multicast_logging(0);
 #endif
 	gwlan_logging.is_flush_complete = false;
-	clear_bit(HOST_LOG_DRIVER_MSG, &gwlan_logging.eventFlag);
-	clear_bit(HOST_LOG_PER_PKT_STATS, &gwlan_logging.eventFlag);
-	clear_bit(HOST_LOG_FW_FLUSH_COMPLETE, &gwlan_logging.eventFlag);
-	clear_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG, &gwlan_logging.eventFlag);
-	clear_bit(HOST_LOG_CHIPSET_STATS, &gwlan_logging.eventFlag);
-	clear_bit(FW_LOG_CHIPSET_STATS, &gwlan_logging.eventFlag);
+	qdf_clear_bit(HOST_LOG_DRIVER_MSG, gwlan_logging.event_flag);
+	qdf_clear_bit(HOST_LOG_PER_PKT_STATS, gwlan_logging.event_flag);
+	qdf_clear_bit(HOST_LOG_FW_FLUSH_COMPLETE, gwlan_logging.event_flag);
+	qdf_clear_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG,
+		      gwlan_logging.event_flag);
+	qdf_clear_bit(HOST_LOG_CHIPSET_STATS, gwlan_logging.event_flag);
+	qdf_clear_bit(FW_LOG_CHIPSET_STATS, gwlan_logging.event_flag);
 	wake_up_interruptible(&gwlan_logging.wait_queue);
 	wait_for_completion(&gwlan_logging.shutdown_comp);
 
@@ -1394,7 +1392,7 @@ void wlan_logging_set_per_pkt_stats(void)
 	if (gwlan_logging.is_active == false)
 		return;
 
-	set_bit(HOST_LOG_PER_PKT_STATS, &gwlan_logging.eventFlag);
+	qdf_set_bit(HOST_LOG_PER_PKT_STATS, gwlan_logging.event_flag);
 	wake_up_interruptible(&gwlan_logging.wait_queue);
 }
 
@@ -1403,7 +1401,7 @@ void wlan_logging_set_connectivity_log(void)
 	if (gwlan_logging.is_active == false)
 		return;
 
-	set_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG, &gwlan_logging.eventFlag);
+	qdf_set_bit(HOST_LOG_DRIVER_CONNECTIVITY_MSG, gwlan_logging.event_flag);
 	wake_up_interruptible(&gwlan_logging.wait_queue);
 }
 
@@ -1421,7 +1419,7 @@ void wlan_logging_set_fw_flush_complete(void)
 	if (!gwlan_logging.is_active)
 		return;
 
-	set_bit(HOST_LOG_FW_FLUSH_COMPLETE, &gwlan_logging.eventFlag);
+	qdf_set_bit(HOST_LOG_FW_FLUSH_COMPLETE, gwlan_logging.event_flag);
 	wake_up_interruptible(&gwlan_logging.wait_queue);
 }
 
@@ -1442,7 +1440,7 @@ void wlan_flush_host_logs_for_fatal(void)
 	spin_lock_irqsave(&gwlan_logging.spin_lock, flags);
 	wlan_queue_logmsg_for_app();
 	spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags);
-	set_bit(HOST_LOG_DRIVER_MSG, &gwlan_logging.eventFlag);
+	qdf_set_bit(HOST_LOG_DRIVER_MSG, gwlan_logging.event_flag);
 	wake_up_interruptible(&gwlan_logging.wait_queue);
 }
 
@@ -1572,7 +1570,7 @@ void wlan_pkt_stats_to_logger_thread(void *pl_hdr, void *pkt_dump, void *data)
 
 	/* Wakeup logger thread */
 	if (true == wake_up_thread) {
-		set_bit(HOST_LOG_PER_PKT_STATS, &gwlan_logging.eventFlag);
+		qdf_set_bit(HOST_LOG_PER_PKT_STATS, gwlan_logging.event_flag);
 		wake_up_interruptible(&gwlan_logging.wait_queue);
 	}
 }
@@ -1865,8 +1863,8 @@ void wlan_register_txrx_packetdump(uint8_t pdev_id)
 #ifdef WLAN_CHIPSET_STATS
 void wlan_set_chipset_stats_bit(void)
 {
-	set_bit(HOST_LOG_CHIPSET_STATS, &gwlan_logging.eventFlag);
-	set_bit(FW_LOG_CHIPSET_STATS, &gwlan_logging.eventFlag);
+	qdf_set_bit(HOST_LOG_CHIPSET_STATS, gwlan_logging.event_flag);
+	qdf_set_bit(FW_LOG_CHIPSET_STATS, gwlan_logging.event_flag);
 }
 #endif /* WLAN_CHIPSET_STATS */
 #endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */