summaryrefslogtreecommitdiff
path: root/lib/fault-inject.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-15 07:57:25 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-15 07:57:25 +0300
commit867eacd7fb975273703766f52f485f08471a1ae9 (patch)
treebe3c024c940d34331d5329a61a8e2be64f21da17 /lib/fault-inject.c
parent077d2ba519b2e8bf1abd80cbade699b1de42cafe (diff)
parent6d7964a722afc8e4f880b947f174009063028c99 (diff)
downloadlinux-867eacd7fb975273703766f52f485f08471a1ae9.tar.xz
Merge branch 'akpm' (patches from Andrew)
Merge even more updates from Andrew Morton: - a few leftovers - fault-injector rework - add a module loader test driver * emailed patches from Andrew Morton <akpm@linux-foundation.org>: kmod: throttle kmod thread limit kmod: add test driver to stress test the module loader MAINTAINERS: give kmod some maintainer love xtensa: use generic fb.h fault-inject: add /proc/<pid>/fail-nth fault-inject: simplify access check for fail-nth fault-inject: make fail-nth read/write interface symmetric fault-inject: parse as natural 1-based value for fail-nth write interface fault-inject: automatically detect the number base for fail-nth write interface kernel/watchdog.c: use better pr_fmt prefix MAINTAINERS: move the befs tree to kernel.org lib/atomic64_test.c: add a test that atomic64_inc_not_zero() returns an int mm: fix overflow check in expand_upwards()
Diffstat (limited to 'lib/fault-inject.c')
-rw-r--r--lib/fault-inject.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/fault-inject.c b/lib/fault-inject.c
index 09ac73c177fd..7d315fdb9f13 100644
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -107,9 +107,12 @@ static inline bool fail_stacktrace(struct fault_attr *attr)
bool should_fail(struct fault_attr *attr, ssize_t size)
{
- if (in_task() && current->fail_nth) {
- if (--current->fail_nth == 0)
+ 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;
+
return false;
}