aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fault-inject.c
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2017-08-10 18:23:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-08-10 18:54:06 -0400
commit9eeb52ae712e72141c4c1d173048a606ba8f42f6 (patch)
treebb6ed5065441552c7d799a839e084e6f0dd23b1d /lib/fault-inject.c
parent4e98ebe5f435fbe5bca91c24bc5d5a2b33025e08 (diff)
fault-inject: fix wrong should_fail() decision in task context
Commit 1203c8e6fb0a ("fault-inject: simplify access check for fail-nth") unintentionally broke a conditional statement in should_fail(). Any faults are not injected in the task context by the change when the systematic fault injection is not used. This change restores to the previous correct behaviour. Link: http://lkml.kernel.org/r/1501633700-3488-1-git-send-email-akinobu.mita@gmail.com Fixes: 1203c8e6fb0a ("fault-inject: simplify access check for fail-nth") Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Reported-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Tested-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Cc: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/fault-inject.c')
-rw-r--r--lib/fault-inject.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/fault-inject.c b/lib/fault-inject.c
index 7d315fdb9f13..cf7b129b0b2b 100644
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -110,10 +110,12 @@ bool should_fail(struct fault_attr *attr, ssize_t size)
110 if (in_task()) { 110 if (in_task()) {
111 unsigned int fail_nth = READ_ONCE(current->fail_nth); 111 unsigned int fail_nth = READ_ONCE(current->fail_nth);
112 112
113 if (fail_nth && !WRITE_ONCE(current->fail_nth, fail_nth - 1)) 113 if (fail_nth) {
114 goto fail; 114 if (!WRITE_ONCE(current->fail_nth, fail_nth - 1))
115 goto fail;
115 116
116 return false; 117 return false;
118 }
117 } 119 }
118 120
119 /* No need to check any other properties if the probability is 0 */ 121 /* No need to check any other properties if the probability is 0 */