log: destroy log_workqueue when the driver exits [1/1]
authorChao Liu <chao.liu@amlogic.com>
Mon, 17 Jan 2022 06:59:14 +0000 (14:59 +0800)
committerBruno Martins <bgcngm@gmail.com>
Sat, 20 Jul 2024 21:20:17 +0000 (22:20 +0100)
PD#SWPL-70250

Problem:
log workqueue is not destroyed and it leads to reboot crash

Solution:
destroy log_workqueue when the driver exits

Verify:
yocto + s4

Signed-off-by: Chao Liu <chao.liu@amlogic.com>
Change-Id: I2b04ae3a719e2779ca6e9b840d2a6832022eafb5

optee/log.c

index adf2bd0c57bf16431dfa26ee6ff2d29c14ef45a4..37bfbce7c43fa5c97e4e7948ceef4b528fbc7b64 100644 (file)
@@ -53,13 +53,12 @@ struct optee_log_ctl_s {
 static struct optee_log_ctl_s *optee_log_ctl;
 static unsigned char *optee_log_buff;
 static uint32_t optee_log_mode = 1;
-static struct timer_list optee_log_timer;
 static uint8_t line_buff[OPTEE_LOG_LINE_MAX];
 static uint32_t looped = 0;
 static void *g_shm_va;
 
 struct delayed_work log_work;
-static struct workqueue_struct *log_workqueue;
+static struct workqueue_struct *log_workqueue = NULL;
 
 static bool init_shm(phys_addr_t shm_pa, uint32_t shm_size)
 {
@@ -343,7 +342,10 @@ void optee_log_exit(struct tee_device *tee_dev)
        int i = 0;
        int n = 0;
 
-       del_timer_sync(&optee_log_timer);
+       if (log_workqueue) {
+               cancel_delayed_work_sync(&log_work);
+               destroy_workqueue(log_workqueue);
+       }
 
        n = sizeof(log_class_attrs) / sizeof(struct class_attribute);
        for (i = 0; i < n; i++)