mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 07:01:23 +00:00
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>
This commit is contained in:
parent
13e2e55601
commit
4862125b02
1 changed files with 8 additions and 3 deletions
|
@ -3636,6 +3636,7 @@ int apply_workqueue_attrs(struct workqueue_struct *wq,
|
||||||
struct workqueue_attrs *new_attrs;
|
struct workqueue_attrs *new_attrs;
|
||||||
struct pool_workqueue *pwq = NULL, *last_pwq;
|
struct pool_workqueue *pwq = NULL, *last_pwq;
|
||||||
struct worker_pool *pool;
|
struct worker_pool *pool;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* only unbound workqueues can change attributes */
|
/* only unbound workqueues can change attributes */
|
||||||
if (WARN_ON(!(wq->flags & WQ_UNBOUND)))
|
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);
|
spin_unlock_irq(&last_pwq->pool->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
ret = 0;
|
||||||
|
/* fall through */
|
||||||
|
out_free:
|
||||||
|
free_workqueue_attrs(new_attrs);
|
||||||
|
return ret;
|
||||||
|
|
||||||
enomem:
|
enomem:
|
||||||
kmem_cache_free(pwq_cache, pwq);
|
kmem_cache_free(pwq_cache, pwq);
|
||||||
free_workqueue_attrs(new_attrs);
|
ret = -ENOMEM;
|
||||||
return -ENOMEM;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int alloc_and_link_pwqs(struct workqueue_struct *wq)
|
static int alloc_and_link_pwqs(struct workqueue_struct *wq)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue