From 8bbc052df4711057692f9a0a816c32c73503e8a2 Mon Sep 17 00:00:00 2001 From: "renjiang.han" Date: Thu, 16 May 2019 16:34:31 +0800 Subject: [PATCH] ppmgr: Add IS_ERR_OR_NULL to determine if the thread exists [1/1] PD#SWPL-8658 Problem: handle is NULL cause kernel panic. Solution: Add IS_ERR_OR_NULL to prevent hanle from being NULL to cause kernel panic. Verify: on T962X2 Change-Id: I3086a497d99646e6475a93b5a53b3c9aca2d2ada Signed-off-by: renjiang.han --- drivers/amlogic/media/video_processor/ppmgr/ppmgr_vpp.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/amlogic/media/video_processor/ppmgr/ppmgr_vpp.c b/drivers/amlogic/media/video_processor/ppmgr/ppmgr_vpp.c index 225b887..1e954a1 100644 --- a/drivers/amlogic/media/video_processor/ppmgr/ppmgr_vpp.c +++ b/drivers/amlogic/media/video_processor/ppmgr/ppmgr_vpp.c @@ -3608,7 +3608,10 @@ int start_ppmgr_task(void) ppmgr_quit_flag = false; task = kthread_run(ppmgr_task, 0, "ppmgr"); } - task_running = 1; + if (!IS_ERR_OR_NULL(task)) + task_running = 1; + else + task = NULL; return 0; } @@ -3617,7 +3620,7 @@ void stop_ppmgr_task(void) #ifdef PPMGR_TB_DETECT stop_tb_task(); #endif - if (task) { + if (!IS_ERR_OR_NULL(task)) { /* send_sig(SIGTERM, task, 1); */ ppmgr_quit_flag = true; up(&thread_sem); @@ -3862,7 +3865,10 @@ int start_tb_task(void) tb_detect_init(); tb_detect_task = kthread_run(tb_task, 0, "tb_detect"); } - tb_task_running = 1; + if (!IS_ERR_OR_NULL(tb_detect_task)) + tb_task_running = 1; + else + tb_detect_task = NULL; return 0; } @@ -3870,7 +3876,7 @@ void stop_tb_task(void) { int val = 0; - if (tb_detect_task) { + if (!IS_ERR_OR_NULL(tb_detect_task)) { tb_quit_flag = true; up(&tb_sem); /* send_sig(SIGTERM, tb_detect_task, 1); */ -- 2.7.4