summaryrefslogtreecommitdiffstats
path: root/kernel/workqueue.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-04-01 14:23:31 -0400
committerTejun Heo <tj@kernel.org>2013-04-01 14:23:31 -0400
commit4862125b0256a946d2749a1d5003b0604bc3cb4d (patch)
tree0091a7104afb64d1ae7db22b880a8f5975ba2dab /kernel/workqueue.c
parent13e2e556013a543eebd238d1c2759195e3c0c9fc (diff)
workqueue: fix memory leak in apply_workqueue_attrs()
apply_workqueue_attrs() wasn't freeing temp attrs variable @new_attrs in its success path. Fix it. Signed-off-by: Tejun Heo <tj@kernel.org> Reported-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r--kernel/workqueue.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index abe1f0da4600..89480fc8eaa3 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3636,6 +3636,7 @@ int apply_workqueue_attrs(struct workqueue_struct *wq,
3636 struct workqueue_attrs *new_attrs; 3636 struct workqueue_attrs *new_attrs;
3637 struct pool_workqueue *pwq = NULL, *last_pwq; 3637 struct pool_workqueue *pwq = NULL, *last_pwq;
3638 struct worker_pool *pool; 3638 struct worker_pool *pool;
3639 int ret;
3639 3640
3640 /* only unbound workqueues can change attributes */ 3641 /* only unbound workqueues can change attributes */
3641 if (WARN_ON(!(wq->flags & WQ_UNBOUND))) 3642 if (WARN_ON(!(wq->flags & WQ_UNBOUND)))
@@ -3668,12 +3669,16 @@ int apply_workqueue_attrs(struct workqueue_struct *wq,
3668 spin_unlock_irq(&last_pwq->pool->lock); 3669 spin_unlock_irq(&last_pwq->pool->lock);
3669 } 3670 }
3670 3671
3671 return 0; 3672 ret = 0;
3673 /* fall through */
3674out_free:
3675 free_workqueue_attrs(new_attrs);
3676 return ret;
3672 3677
3673enomem: 3678enomem:
3674 kmem_cache_free(pwq_cache, pwq); 3679 kmem_cache_free(pwq_cache, pwq);
3675 free_workqueue_attrs(new_attrs); 3680 ret = -ENOMEM;
3676 return -ENOMEM; 3681 goto out_free;
3677} 3682}
3678 3683
3679static int alloc_and_link_pwqs(struct workqueue_struct *wq) 3684static int alloc_and_link_pwqs(struct workqueue_struct *wq)