* [PATCH -next] locking/ww_mutex: fix missing destroy_workqueue() on error in test_ww_mutex_init()
@ 2021-04-01 9:33 Yang Yingliang
0 siblings, 0 replies; only message in thread
From: Yang Yingliang @ 2021-04-01 9:33 UTC (permalink / raw)
To: linux-kernel; +Cc: mingo, peterz
If test_ww_mutex_init() failed, the module won't be loaded,
so test_ww_mutex_exit() can not be called, in this case, wq
will be leaked, fix it by adding destroy_workqueue() on error
path of test_ww_mutex_init().
Fixes: d1b42b800e5d ("locking/ww_mutex: Add kselftests for resolving...")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
kernel/locking/test-ww_mutex.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index 3e82f449b4ff..6e4faa853e56 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -589,37 +589,41 @@ static int __init test_ww_mutex_init(void)
ret = test_mutex();
if (ret)
- return ret;
+ goto out;
ret = test_aa();
if (ret)
- return ret;
+ goto out;
ret = test_abba(false);
if (ret)
- return ret;
+ goto out;
ret = test_abba(true);
if (ret)
- return ret;
+ goto out;
ret = test_cycle(ncpus);
if (ret)
- return ret;
+ goto out;
ret = stress(16, 2*ncpus, STRESS_INORDER);
if (ret)
- return ret;
+ goto out;
ret = stress(16, 2*ncpus, STRESS_REORDER);
if (ret)
- return ret;
+ goto out;
ret = stress(4095, hweight32(STRESS_ALL)*ncpus, STRESS_ALL);
if (ret)
- return ret;
+ goto out;
return 0;
+
+out:
+ destroy_workqueue(wq);
+ return ret;
}
static void __exit test_ww_mutex_exit(void)
--
2.25.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-01 9:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01 9:33 [PATCH -next] locking/ww_mutex: fix missing destroy_workqueue() on error in test_ww_mutex_init() Yang Yingliang
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).