wlan: Add protection for logging buffer NULL check.
Protect logging buffer(gwlan_logging.pcur_node) NULL check, to avoid
possible race condition of dereferencing logging buffer after making it
NULL.
Change-Id: Ie1f805bf027bf2dd6d786927341384ec117ac28d
CRs-Fixed: 768344
diff --git a/CORE/SVC/src/logging/wlan_logging_sock_svc.c b/CORE/SVC/src/logging/wlan_logging_sock_svc.c
index 16c0159..7a0b678 100644
--- a/CORE/SVC/src/logging/wlan_logging_sock_svc.c
+++ b/CORE/SVC/src/logging/wlan_logging_sock_svc.c
@@ -309,11 +309,6 @@
pr_err("%s\n", to_be_sent);
}
- // wlan logging svc resources are not yet initialized
- if (!gwlan_logging.pcur_node) {
- return -EIO;
- }
-
/* Format the Log time [Secondselapsedinaday.microseconds] */
do_gettimeofday(&tv);
tlen = snprintf(tbuf, sizeof(tbuf), "[%s][%5lu.%06lu] ", current->comm,
@@ -325,6 +320,12 @@
spin_lock_irqsave(&gwlan_logging.spin_lock, flags);
+ // wlan logging svc resources are not yet initialized
+ if (!gwlan_logging.pcur_node) {
+ spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags);
+ return -EIO;
+ }
+
pfilled_length = &gwlan_logging.pcur_node->filled_length;
/* Check if we can accomodate more log into current node/buffer */