Messages in this thread Patch in this message | | | From | Yang Yingliang <> | Subject | [PATCH -next] locking/ww_mutex: fix missing destroy_workqueue() on error in test_ww_mutex_init() | Date | Thu, 1 Apr 2021 17:33:58 +0800 |
| |
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
| |