Commit 9eeb52ae authored by Akinobu Mita's avatar Akinobu Mita Committed by Linus Torvalds

fault-inject: fix wrong should_fail() decision in task context

Commit 1203c8e6 ("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.

Fixes: 1203c8e6 ("fault-inject: simplify access check for fail-nth")
Signed-off-by: default avatarAkinobu Mita <>
Reported-by: default avatarLu Fengqi <>
Tested-by: default avatarLu Fengqi <>
Cc: Dmitry Vyukov <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 4e98ebe5
......@@ -110,10 +110,12 @@ bool should_fail(struct fault_attr *attr, ssize_t size)
if (in_task()) {
unsigned int fail_nth = READ_ONCE(current->fail_nth);
if (fail_nth && !WRITE_ONCE(current->fail_nth, fail_nth - 1))
goto fail;
if (fail_nth) {
if (!WRITE_ONCE(current->fail_nth, fail_nth - 1))
goto fail;
return false;
return false;
/* No need to check any other properties if the probability is 0 */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment