Skip to contentSkip to conversation

workqueue, lockdep: Fix new alloc_workqueue() error path

PATCH In review Kefeng Wang 1 participant 2 messages Mar 18, 2019 Workqueue

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 workqueue, lockdep: Fix new alloc_workqueue() error path

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 <[email protected]>
Cc Bart Van Assche <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Fixes 009bb421b6ce ("workqueue, lockdep: Fix an alloc_workqueue() error path")
---
 kernel/workqueue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/workqueue.c +2 -1
index 4026d1871407..2c19f2968bc7 100644
@@ -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:
Signature · 1 line
2.20.1
#1 lore raw

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

Quoted 36 lines · Kefeng Wang

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 <[email protected]>
Cc Bart Van Assche <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Fixes 009bb421b6ce ("workqueue, lockdep: Fix an alloc_workqueue() error path")
---
 kernel/workqueue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/workqueue.c +2 -1
index 4026d1871407..2c19f2968bc7 100644
@@ -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: