OSDN Git Service

msm: sde: Avoid NULL pointer dereference in cancel request
authorKrishna Chaitanya Devarakonda <kdevarak@codeaurora.org>
Thu, 31 Aug 2017 15:54:53 +0000 (21:24 +0530)
committerGerrit - the friendly Code Review server <code-review@localhost>
Tue, 5 Sep 2017 05:43:21 +0000 (22:43 -0700)
There is a race condition possible when two threads are calling
the rotator cancel request. This might result in accessing a pointer
which was already assigned NULL. Fixing this by adding an extra check.

Change-Id: I9ce321a5f033d1fdc9d8b70a04098bfba3d7baaa
Signed-off-by: Krishna Chaitanya Devarakonda <kdevarak@codeaurora.org>
drivers/media/platform/msm/sde/rotator/sde_rotator_core.c

index abf20ae..422c7a5 100644 (file)
@@ -2003,8 +2003,10 @@ static void sde_rotator_cancel_request(struct sde_rot_mgr *mgr,
                sde_rot_mgr_unlock(mgr);
                for (i = req->count - 1; i >= 0; i--) {
                        entry = req->entries + i;
-                       flush_kthread_worker(&entry->commitq->rot_kw);
-                       flush_kthread_worker(&entry->doneq->rot_kw);
+                       if (entry->commitq)
+                               flush_kthread_worker(&entry->commitq->rot_kw);
+                       if (entry->doneq)
+                               flush_kthread_worker(&entry->doneq->rot_kw);
                }
                sde_rot_mgr_lock(mgr);
                SDEROT_DBG("cancel work done\n");