qcacmn: Add SSR protection to os_if_wifi_pos_callback()

Protect SSR protection for wifi pos callback function to prevent
possible race condition between user request and driver unload.

Change-Id: I68d3636429f8891f0a4d6c78642aeecf7d67e105
CRs-Fixed: 2349354
diff --git a/os_if/linux/wifi_pos/src/os_if_wifi_pos.c b/os_if/linux/wifi_pos/src/os_if_wifi_pos.c
index e061c73..9c73562 100644
--- a/os_if/linux/wifi_pos/src/os_if_wifi_pos.c
+++ b/os_if/linux/wifi_pos/src/os_if_wifi_pos.c
@@ -22,6 +22,7 @@
  * component's os_if layer.
  */
 
+#include "qdf_platform.h"
 #include "wlan_nlink_srv.h"
 #include "wlan_ptt_sock_svc.h"
 #include "wlan_nlink_common.h"
@@ -149,15 +150,15 @@
 #endif
 
 /**
- * os_if_wifi_pos_callback() - callback registered with NL service socket to
+ * __os_if_wifi_pos_callback() - callback registered with NL service socket to
  * process wifi pos request
  * @skb: request message sk_buff
  *
  * Return: status of operation
  */
 #ifdef CNSS_GENL
-static void os_if_wifi_pos_callback(const void *data, int data_len,
-				    void *ctx, int pid)
+static void __os_if_wifi_pos_callback(const void *data, int data_len,
+				      void *ctx, int pid)
 {
 	uint8_t err;
 	QDF_STATUS status;
@@ -187,8 +188,20 @@
 release_psoc_ref:
 	wlan_objmgr_psoc_release_ref(psoc, WLAN_WIFI_POS_OSIF_ID);
 }
+
+static void os_if_wifi_pos_callback(const void *data, int data_len,
+				    void *ctx, int pid)
+{
+	struct qdf_op_sync *op_sync;
+
+	if (qdf_op_protect(&op_sync))
+		return;
+
+	__os_if_wifi_pos_callback(data, data_len, ctx, pid);
+	qdf_op_unprotect(op_sync);
+}
 #else
-static int os_if_wifi_pos_callback(struct sk_buff *skb)
+static int __os_if_wifi_pos_callback(struct sk_buff *skb)
 {
 	uint8_t err;
 	QDF_STATUS status;
@@ -220,6 +233,20 @@
 
 	return qdf_status_to_os_return(status);
 }
+
+static int os_if_wifi_pos_callback(struct sk_buff *skb)
+{
+	struct qdf_op_sync *op_sync;
+	int err;
+
+	if (qdf_op_protect(&op_sync))
+		return -EINVAL;
+
+	err = __os_if_wifi_pos_callback(skb);
+	qdf_op_unprotect(op_sync);
+
+	return err;
+}
 #endif
 
 #ifdef CNSS_GENL
diff --git a/qdf/inc/qdf_platform.h b/qdf/inc/qdf_platform.h
index 1195b12..9225e55 100644
--- a/qdf/inc/qdf_platform.h
+++ b/qdf/inc/qdf_platform.h
@@ -24,6 +24,8 @@
 #ifndef _QDF_PLATFORM_H
 #define _QDF_PLATFORM_H
 
+#include "qdf_types.h"
+
 /**
  * qdf_self_recovery_callback() - callback for self recovery
  * @reason: the reason for the recovery request