Ver Fonte

qcacld-3.0: Deregister NL MSG handlers during hdd_wlan_exit

Currently the NL MSG handlers for WLAN_NL_MSG_OEM and
WLAN_NL_MSG_SPECTRAL_SCAN are not deregistered during hdd_wlan_exit which
can causes a page fault if NL issues cld80211_doit for these NL messages
when the WLAN is not up.

Add Deregister APIs for all the NL MSGs to call as part of
hdd_exit_netlink_services during hdd_wlan_exit.

Change-Id: I5811dcfc79eff4ea7281de5f7591e078c572e69c
CRs-Fixed: 2232902
Vignesh Viswanathan há 6 anos atrás
pai
commit
a1cb4b47ce

+ 24 - 0
core/hdd/inc/wlan_hdd_oemdata.h

@@ -177,8 +177,27 @@ void hdd_send_peer_status_ind_to_oem_app(struct qdf_mac_addr *peerMac,
 int iw_get_oem_data_cap(struct net_device *dev, struct iw_request_info *info,
 			union iwreq_data *wrqu, char *extra);
 
+/**
+ * oem_activate_service() - API to register the oem command handler
+ * @hdd_ctx: Pointer to HDD Context
+ *
+ * This API is used to register the handler to receive netlink message
+ * from an OEM application process
+ *
+ * Return: 0 on success and errno on failure
+ */
 int oem_activate_service(struct hdd_context *hdd_ctx);
 
+/**
+ * oem_deactivate_service() - API to unregister the oem command handler
+ *
+ * This API is used to deregister the handler to receive netlink message
+ * from an OEM application process
+ *
+ * Return: 0 on success and errno on failure
+ */
+int oem_deactivate_service(void);
+
 void hdd_send_oem_data_rsp_msg(struct oem_data_rsp *oem_rsp);
 void hdd_update_channel_bw_info(struct hdd_context *hdd_ctx,
 				uint16_t chan,
@@ -189,6 +208,11 @@ static inline int oem_activate_service(struct hdd_context *hdd_ctx)
 	return 0;
 }
 
+static inline int oem_deactivate_service(void)
+{
+	return 0;
+}
+
 static inline void hdd_send_oem_data_rsp_msg(void *oem_rsp) {}
 
 static inline void hdd_update_channel_bw_info(struct hdd_context *hdd_ctx,

+ 19 - 6
core/hdd/inc/wlan_hdd_spectralscan.h

@@ -194,16 +194,29 @@ int wlan_hdd_cfg80211_spectral_scan_get_status(struct wiphy *wiphy,
 /**
  * spectral_scan_activate_service() - Activate spectral scan  message handler
  *
- *  This function registers a handler to receive netlink message from
- *  the spectral scan application process.
+ * This function registers a handler to receive netlink message from
+ * the spectral scan application process.
  *
- * Return - 0 for success, non zero for failure
+ * Return: None
  */
-int spectral_scan_activate_service(void);
+void spectral_scan_activate_service(void);
+
+/**
+ * spectral_scan_deactivate_service() - Deactivate spectral scan message handler
+ *
+ * This function deregisters a handler to receive netlink message from
+ * the spectral scan application process.
+ *
+ * Return: None
+ */
+void spectral_scan_deactivate_service(void);
 #else
-static inline int spectral_scan_activate_service(void)
+static inline void spectral_scan_activate_service(void)
+{
+}
+
+static inline void spectral_scan_deactivate_service(void)
 {
-	return 0;
 }
 #endif
 #endif

+ 7 - 12
core/hdd/src/wlan_hdd_main.c

@@ -2962,7 +2962,7 @@ static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx)
 
 static int hdd_deactivate_wifi_pos(void)
 {
-	return 0;
+	return oem_deactivate_service();
 }
 
 static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx)
@@ -6640,9 +6640,11 @@ void hdd_unregister_notifiers(struct hdd_context *hdd_ctx)
  */
 static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx)
 {
+	spectral_scan_deactivate_service();
+	cnss_diag_deactivate_service();
 	hdd_close_cesium_nl_sock();
-	hdd_deactivate_wifi_pos();
 	ptt_sock_deactivate_svc();
+	hdd_deactivate_wifi_pos();
 
 	nl_srv_exit();
 }
@@ -6673,11 +6675,7 @@ static int hdd_init_netlink_services(struct hdd_context *hdd_ctx)
 		goto err_nl_srv;
 	}
 
-	ret = ptt_sock_activate_svc();
-	if (ret) {
-		hdd_err("ptt_sock_activate_svc failed: %d", ret);
-		goto err_nl_srv;
-	}
+	ptt_sock_activate_svc();
 
 	ret = hdd_open_cesium_nl_sock();
 	if (ret)
@@ -6689,17 +6687,14 @@ static int hdd_init_netlink_services(struct hdd_context *hdd_ctx)
 		goto err_close_cesium;
 	}
 
-	ret = spectral_scan_activate_service();
-	if (ret) {
-		hdd_err("spectral service initialization failed: %d", ret);
-		goto err_close_cesium;
-	}
+	spectral_scan_activate_service();
 
 	return 0;
 
 err_close_cesium:
 	hdd_close_cesium_nl_sock();
 	ptt_sock_deactivate_svc();
+	hdd_deactivate_wifi_pos();
 err_nl_srv:
 	nl_srv_exit();
 out:

+ 13 - 19
core/hdd/src/wlan_hdd_oemdata.c

@@ -1035,21 +1035,18 @@ static void oem_cmd_handler(const void *data, int data_len, void *ctx, int pid)
 	oem_request_dispatcher(msg_hdr, pid);
 }
 
-/**
- * oem_activate_service() - API to register the oem command handler
- * @hdd_ctx: Pointer to HDD Context
- *
- * This API is used to register the oem app command handler. Argument
- * @adapter is given for prototype compatibility with legacy code.
- *
- * Return: 0
- */
 int oem_activate_service(struct hdd_context *hdd_ctx)
 {
 	p_hdd_ctx = hdd_ctx;
 	register_cld_cmd_cb(WLAN_NL_MSG_OEM, oem_cmd_handler, NULL);
 	return 0;
 }
+
+int oem_deactivate_service(void)
+{
+	deregister_cld_cmd_cb(WLAN_NL_MSG_OEM);
+	return 0;
+}
 #else
 
 /*
@@ -1116,16 +1113,6 @@ static int __oem_msg_callback(struct sk_buff *skb)
 	return ret;
 }
 
-/**
- * oem_activate_service() - Activate oem message handler
- * @hdd_ctx:   pointer to global HDD context
- *
- * This function registers a handler to receive netlink message from
- * an OEM application process.
- *
- * Return: zero on success
- *         On error, error number will be returned.
- */
 int oem_activate_service(struct hdd_context *hdd_ctx)
 {
 	p_hdd_ctx = hdd_ctx;
@@ -1133,5 +1120,12 @@ int oem_activate_service(struct hdd_context *hdd_ctx)
 	/* Register the msg handler for msgs addressed to WLAN_NL_MSG_OEM */
 	return nl_srv_register(WLAN_NL_MSG_OEM, __oem_msg_callback);
 }
+
+int oem_deactivate_service(void)
+{
+	/* Deregister the msg handler for msgs addressed to WLAN_NL_MSG_OEM */
+	return nl_srv_unregister(WLAN_NL_MSG_OEM, __oem_msg_callback);
+}
+
 #endif
 #endif

+ 7 - 13
core/hdd/src/wlan_hdd_spectralscan.c

@@ -463,20 +463,14 @@ static void spectral_scan_msg_handler(const void *data, int data_len,
 	cds_ssr_unprotect(__func__);
 }
 
-/**
- * spectral_scan_activate_service() - API to register spectral
- * scan cmd handler
- *
- * API to register the spectral scan command handler using new
- * genl infra. Return type is zero to match with legacy
- * prototype
- *
- * Return: 0
- */
-int spectral_scan_activate_service(void)
+void spectral_scan_activate_service(void)
 {
 	register_cld_cmd_cb(WLAN_NL_MSG_SPECTRAL_SCAN,
-				spectral_scan_msg_handler, NULL);
-	return 0;
+			    spectral_scan_msg_handler, NULL);
+}
+
+void spectral_scan_deactivate_service(void)
+{
+	deregister_cld_cmd_cb(WLAN_NL_MSG_SPECTRAL_SCAN);
 }
 #endif