fault-inject: fix wrong should_fail() decision in task context
Commit1203c8e6fb
("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:1203c8e6fb
("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>
This commit is contained in:
parent
4e98ebe5f4
commit
9eeb52ae71
|
@ -110,11 +110,13 @@ 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))
|
||||
if (fail_nth) {
|
||||
if (!WRITE_ONCE(current->fail_nth, fail_nth - 1))
|
||||
goto fail;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* No need to check any other properties if the probability is 0 */
|
||||
if (attr->probability == 0)
|
||||
|
|
Loading…
Reference in New Issue