diff options
author | Tejun Heo <tj@kernel.org> | 2013-04-01 20:23:31 +0200 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-04-01 20:23:31 +0200 |
commit | 4862125b0256a946d2749a1d5003b0604bc3cb4d (patch) | |
tree | 0091a7104afb64d1ae7db22b880a8f5975ba2dab /kernel/workqueue.c | |
parent | workqueue: fix unbound workqueue attrs hashing / comparison (diff) | |
download | linux-4862125b0256a946d2749a1d5003b0604bc3cb4d.tar.xz linux-4862125b0256a946d2749a1d5003b0604bc3cb4d.zip |
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.c | 11 |
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, struct workqueue_attrs *new_attrs; struct pool_workqueue *pwq = NULL, *last_pwq; struct worker_pool *pool; + int ret; /* only unbound workqueues can change attributes */ if (WARN_ON(!(wq->flags & WQ_UNBOUND))) @@ -3668,12 +3669,16 @@ int apply_workqueue_attrs(struct workqueue_struct *wq, spin_unlock_irq(&last_pwq->pool->lock); } - return 0; + ret = 0; + /* fall through */ +out_free: + free_workqueue_attrs(new_attrs); + return ret; enomem: kmem_cache_free(pwq_cache, pwq); - free_workqueue_attrs(new_attrs); - return -ENOMEM; + ret = -ENOMEM; + goto out_free; } static int alloc_and_link_pwqs(struct workqueue_struct *wq) |