workqueue: avoid process_one_work NULL reference
authorAo Xu <ao.xu@amlogic.com>
Wed, 7 Feb 2018 08:23:04 +0000 (16:23 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Fri, 9 Mar 2018 10:58:27 +0000 (02:58 -0800)
PD#158184: avoid process_one_work NULL reference

avoid process_one_work NULL reference

Change-Id: I96d9477b804e079e18663d8f80d714ed9fbbd642
Signed-off-by: Ao Xu <ao.xu@amlogic.com>
kernel/workqueue.c

index 181c2ad..c272428 100644 (file)
@@ -2013,11 +2013,20 @@ static void process_one_work(struct worker *worker, struct work_struct *work)
 __releases(&pool->lock)
 __acquires(&pool->lock)
 {
+#ifdef CONFIG_AMLOGIC_MODIFY
+       int work_color;
+       struct worker *collision;
+       bool cpu_intensive;
+       struct pool_workqueue *pwq = get_work_pwq(work);
+       struct worker_pool *pool = worker->pool;
+#else
        struct pool_workqueue *pwq = get_work_pwq(work);
        struct worker_pool *pool = worker->pool;
        bool cpu_intensive = pwq->wq->flags & WQ_CPU_INTENSIVE;
        int work_color;
        struct worker *collision;
+#endif
+
 #ifdef CONFIG_LOCKDEP
        /*
         * It is permissible to free the struct work_struct from
@@ -2030,6 +2039,14 @@ __acquires(&pool->lock)
 
        lockdep_copy_map(&lockdep_map, &work->lockdep_map);
 #endif
+#ifdef CONFIG_AMLOGIC_MODIFY
+       if (!pwq) {
+               WARN_ONCE(1, "Warning: pool_workqueue is NULL!!!!!!!!!!!!.\n");
+               return;
+       }
+
+       cpu_intensive = pwq->wq->flags & WQ_CPU_INTENSIVE;
+#endif
        /* ensure we're on the correct CPU */
        WARN_ON_ONCE(!(pool->flags & POOL_DISASSOCIATED) &&
                     raw_smp_processor_id() != pool->cpu);