Browse Source

touch: derefernce NULL pointer during shutdown

dereference NULL pointers during shutdown and remove calls.

Change-Id: Ifae6edbc87d12a3f77cff6d2fd4bb9e4d24591ae
Signed-off-by: Surya Teja Kudiri <quic_skudiri@quicinc.com>
Surya Teja Kudiri 2 years ago
parent
commit
8b1e6c6e0b
1 changed files with 17 additions and 6 deletions
  1. 17 6
      raydium/raydium_driver.c

+ 17 - 6
raydium/raydium_driver.c

@@ -1300,8 +1300,10 @@ static irqreturn_t raydium_ts_interrupt(int irq, void *dev_id)
 	} else {
 		if (!work_pending(&g_raydium_ts->work)) {
 			/* Clear interrupts*/
-			result = queue_work(g_raydium_ts->workqueue,
-					    &g_raydium_ts->work);
+			if (g_raydium_ts->workqueue) {
+				result = queue_work(g_raydium_ts->workqueue,
+						&g_raydium_ts->work);
+			}
 
 			if (!result) {
 				/*queue_work fail*/
@@ -2512,6 +2514,9 @@ exit_check_functionality_failed:
 void raydium_ts_shutdown(struct i2c_client *client)
 {
 
+	LOGD(LOG_INFO, "[touch] %s: start\n", __func__);
+
+	cancel_work_sync(&g_raydium_ts->work);
 	if (g_raydium_ts->workqueue) {
 		destroy_workqueue(g_raydium_ts->workqueue);
 		g_raydium_ts->workqueue = NULL;
@@ -2546,22 +2551,26 @@ if (active_panel)
 	if (gpio_is_valid(g_raydium_ts->irq_gpio))
 		gpio_free(g_raydium_ts->irq_gpio);
 
+
 	raydium_enable_regulator(g_raydium_ts, false);
 	raydium_get_regulator(g_raydium_ts, false);
 
 	kfree(g_raydium_ts);
 
 	i2c_set_clientdata(client, NULL);
+	LOGD(LOG_INFO, "[touch] %s: done\n", __func__);
 }
 
 static int raydium_ts_remove(struct i2c_client *client)
 {
 
-        if (g_raydium_ts->workqueue) {
-                destroy_workqueue(g_raydium_ts->workqueue);
-                g_raydium_ts->workqueue = NULL;
-        }
+	LOGD(LOG_INFO, "[touch] %s: start\n", __func__);
 
+	cancel_work_sync(&g_raydium_ts->work);
+	if (g_raydium_ts->workqueue) {
+		destroy_workqueue(g_raydium_ts->workqueue);
+		g_raydium_ts->workqueue = NULL;
+	}
 #if defined(CONFIG_FB)
 	raydium_unregister_notifier();
 #elif defined(CONFIG_HAS_EARLYSUSPEND)
@@ -2590,12 +2599,14 @@ if (active_panel)
 	if (gpio_is_valid(g_raydium_ts->irq_gpio))
 		gpio_free(g_raydium_ts->irq_gpio);
 
+
 	raydium_enable_regulator(g_raydium_ts, false);
 	raydium_get_regulator(g_raydium_ts, false);
 
 	kfree(g_raydium_ts);
 
 	i2c_set_clientdata(client, NULL);
+	LOGD(LOG_INFO, "[touch] %s: done\n", __func__);
 	return 0;
 }