]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.181/rcutorture-fix-cleanup-path-for-invalid-torture_type.patch
Linux 4.9.181
[thirdparty/kernel/stable-queue.git] / releases / 4.4.181 / rcutorture-fix-cleanup-path-for-invalid-torture_type.patch
1 From 934b974e4b3d1245ba60db9061e98da902eb8291 Mon Sep 17 00:00:00 2001
2 From: "Paul E. McKenney" <paulmck@linux.ibm.com>
3 Date: Thu, 21 Mar 2019 09:27:28 -0700
4 Subject: rcutorture: Fix cleanup path for invalid torture_type strings
5
6 [ Upstream commit b813afae7ab6a5e91b4e16cc567331d9c2ae1f04 ]
7
8 If the specified rcutorture.torture_type is not in the rcu_torture_init()
9 function's torture_ops[] array, rcutorture prints some console messages
10 and then invokes rcu_torture_cleanup() to set state so that a future
11 torture test can run. However, rcu_torture_cleanup() also attempts to
12 end the test that didn't actually start, and in doing so relies on the
13 value of cur_ops, a value that is not particularly relevant in this case.
14 This can result in confusing output or even follow-on failures due to
15 attempts to use facilities that have not been properly initialized.
16
17 This commit therefore sets the value of cur_ops to NULL in this case
18 and inserts a check near the beginning of rcu_torture_cleanup(),
19 thus avoiding relying on an irrelevant cur_ops value.
20
21 Reported-by: kernel test robot <rong.a.chen@intel.com>
22 Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
23 Signed-off-by: Sasha Levin <sashal@kernel.org>
24 ---
25 kernel/rcu/rcutorture.c | 5 +++++
26 1 file changed, 5 insertions(+)
27
28 diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
29 index d89328e260df6..041a02b334d73 100644
30 --- a/kernel/rcu/rcutorture.c
31 +++ b/kernel/rcu/rcutorture.c
32 @@ -1603,6 +1603,10 @@ rcu_torture_cleanup(void)
33 cur_ops->cb_barrier();
34 return;
35 }
36 + if (!cur_ops) {
37 + torture_cleanup_end();
38 + return;
39 + }
40
41 rcu_torture_barrier_cleanup();
42 torture_stop_kthread(rcu_torture_stall, stall_task);
43 @@ -1741,6 +1745,7 @@ rcu_torture_init(void)
44 pr_alert(" %s", torture_ops[i]->name);
45 pr_alert("\n");
46 firsterr = -EINVAL;
47 + cur_ops = NULL;
48 goto unwind;
49 }
50 if (cur_ops->fqs == NULL && fqs_duration != 0) {
51 --
52 2.20.1
53