]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - lib/fault-inject.c
kernel/watchdog: Prevent false positives with turbo modes
[mirror_ubuntu-artful-kernel.git] / lib / fault-inject.c
index 09ac73c177fd555b86ef8b3a155ee1043258b532..cf7b129b0b2b08adcc1aae98f990c384761532dc 100644 (file)
@@ -107,10 +107,15 @@ 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)
-                       goto fail;
-               return false;
+       if (in_task()) {
+               unsigned int fail_nth = READ_ONCE(current->fail_nth);
+
+               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 */