workqueue: free rescuer on destroy_workqueue
authorXiaotian Feng <dfeng@redhat.com>
Mon, 16 Aug 2010 07:54:28 +0000 (09:54 +0200)
committerTejun Heo <tj@kernel.org>
Mon, 16 Aug 2010 07:55:01 +0000 (09:55 +0200)
wq->rescuer is not freed when wq is destroyed, leads a memory leak
then. This patch also remove a redundant line.

Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
kernel/workqueue.c

index 2994a0e3a61cc2cfdeb382936394456875a4c01c..1001b6e3fcbd1d3ffb34bc5bee2c2b9d83e3c1f7 100644 (file)
@@ -2782,7 +2782,6 @@ struct workqueue_struct *__alloc_workqueue_key(const char *name,
                if (IS_ERR(rescuer->task))
                        goto err;
 
-               wq->rescuer = rescuer;
                rescuer->task->flags |= PF_THREAD_BOUND;
                wake_up_process(rescuer->task);
        }
@@ -2848,6 +2847,7 @@ void destroy_workqueue(struct workqueue_struct *wq)
        if (wq->flags & WQ_RESCUER) {
                kthread_stop(wq->rescuer->task);
                free_mayday_mask(wq->mayday_mask);
+               kfree(wq->rescuer);
        }
 
        free_cwqs(wq);