From d85652151eeeebcf014e801583ca80b299eeb467 Mon Sep 17 00:00:00 2001 From: "renjiang.han" Date: Tue, 25 Jun 2019 20:02:40 +0800 Subject: [PATCH] amlvideo2: null pointer causes panic. [1/1] PD#TV-7022 Problem: A null pointer causes panic. Solution: Add a judgment on the null pointer in the amlvideo2_stop_thread function. Verify: on x301 Change-Id: Ic2cb9476fa97e27fe8b1160d74330d1ba7bc93a8 Signed-off-by: renjiang.han --- .../media/video_processor/video_dev/amlvideo2.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/amlogic/media/video_processor/video_dev/amlvideo2.c b/drivers/amlogic/media/video_processor/video_dev/amlvideo2.c index 7701e7d8d8ab..dd492c5c9fee 100644 --- a/drivers/amlogic/media/video_processor/video_dev/amlvideo2.c +++ b/drivers/amlogic/media/video_processor/video_dev/amlvideo2.c @@ -4096,8 +4096,13 @@ static int amlvideo2_start_thread(struct amlvideo2_fh *fh) static void amlvideo2_stop_thread(struct amlvideo2_node_dmaqueue *dma_q) { int ret = 0; - struct amlvideo2_node *node = - container_of(dma_q, struct amlvideo2_node, vidq); + struct amlvideo2_node *node; + + if (IS_ERR_OR_NULL(dma_q)) { + pr_info("dma_q is NULL\n"); + return; + } + node = container_of(dma_q, struct amlvideo2_node, vidq); dpr_err(node->vid_dev, 1, "%s\n", __func__); if (amlvideo2_dbg_en & 1) { if (node->vid == 0) @@ -4107,7 +4112,7 @@ static void amlvideo2_stop_thread(struct amlvideo2_node_dmaqueue *dma_q) } mutex_lock(&node->mutex); /* shutdown control thread */ - if (!IS_ERR(dma_q->kthread)) { + if (!IS_ERR_OR_NULL(dma_q->kthread)) { dma_q->task_running = 0; send_sig(SIGTERM, dma_q->kthread, 1); #ifdef USE_SEMA_QBUF