linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] workqueue, lockdep: Fix new alloc_workqueue() error path
@ 2019-03-18 11:58 Kefeng Wang
  2019-03-18 12:32 ` Kefeng Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Kefeng Wang @ 2019-03-18 11:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: Kefeng Wang, Andrew Morton, Bart Van Assche, Ingo Molnar,
	Tejun Heo, Peter Zijlstra

If alloc_workqueue_attrs() fails, the workqueue lockdep is
uninitialized, it will trigger a warning in err_free_wq path
when try to unregister workqueue lockdep.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Fixes: 009bb421b6ce ("workqueue, lockdep: Fix an alloc_workqueue() error path")
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 kernel/workqueue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 4026d1871407..2c19f2968bc7 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4242,7 +4242,7 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
 	if (flags & WQ_UNBOUND) {
 		wq->unbound_attrs = alloc_workqueue_attrs(GFP_KERNEL);
 		if (!wq->unbound_attrs)
-			goto err_free_wq;
+			goto err_unbound_attrs;
 	}
 
 	va_start(args, max_active);
@@ -4296,6 +4296,7 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
 	wq_unregister_lockdep(wq);
 	wq_free_lockdep(wq);
 	free_workqueue_attrs(wq->unbound_attrs);
+err_unbound_attrs:
 	kfree(wq);
 	return NULL;
 err_destroy:
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] workqueue, lockdep: Fix new alloc_workqueue() error path
  2019-03-18 11:58 [PATCH] workqueue, lockdep: Fix new alloc_workqueue() error path Kefeng Wang
@ 2019-03-18 12:32 ` Kefeng Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Kefeng Wang @ 2019-03-18 12:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Morton, Bart Van Assche, Ingo Molnar, Tejun Heo, Peter Zijlstra

Please ignore, no check lkml again,  see https://lkml.org/lkml/2019/3/11/1274:-)

On 2019/3/18 19:58, Kefeng Wang wrote:
> If alloc_workqueue_attrs() fails, the workqueue lockdep is
> uninitialized, it will trigger a warning in err_free_wq path
> when try to unregister workqueue lockdep.
>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Bart Van Assche <bvanassche@acm.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Fixes: 009bb421b6ce ("workqueue, lockdep: Fix an alloc_workqueue() error path")
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  kernel/workqueue.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 4026d1871407..2c19f2968bc7 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -4242,7 +4242,7 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
>  	if (flags & WQ_UNBOUND) {
>  		wq->unbound_attrs = alloc_workqueue_attrs(GFP_KERNEL);
>  		if (!wq->unbound_attrs)
> -			goto err_free_wq;
> +			goto err_unbound_attrs;
>  	}
>  
>  	va_start(args, max_active);
> @@ -4296,6 +4296,7 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
>  	wq_unregister_lockdep(wq);
>  	wq_free_lockdep(wq);
>  	free_workqueue_attrs(wq->unbound_attrs);
> +err_unbound_attrs:
>  	kfree(wq);
>  	return NULL;
>  err_destroy:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-18 12:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18 11:58 [PATCH] workqueue, lockdep: Fix new alloc_workqueue() error path Kefeng Wang
2019-03-18 12:32 ` Kefeng Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).