lkml.org 
[lkml]   [2021]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -next] locking/ww_mutex: fix missing destroy_workqueue() on error in test_ww_mutex_init()
Date
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
\
 
 \ /
  Last update: 2021-04-01 11:32    [W:0.124 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site