Skip to content

Commit

Permalink
fault-inject: fix wrong should_fail() decision in task context
Browse files Browse the repository at this point in the history
Commit 1203c8e ("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/[email protected]
Fixes: 1203c8e ("fault-inject: simplify access check for fail-nth")
Signed-off-by: Akinobu Mita <[email protected]>
Reported-by: Lu Fengqi <[email protected]>
Tested-by: Lu Fengqi <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
mita authored and torvalds committed Aug 10, 2017
1 parent 4e98ebe commit 9eeb52a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/fault-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 9eeb52a

Please sign in to comment.