include/linux/string.h: add the option of fortified string.h functions
[sfrench/cifs-2.6.git] / lib / fault-inject.c
index 4ff157159a0d4d9d746fad5d228e878bdecd5be2..09ac73c177fd555b86ef8b3a155ee1043258b532 100644 (file)
@@ -107,6 +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)
+                       goto fail;
+               return false;
+       }
+
        /* No need to check any other properties if the probability is 0 */
        if (attr->probability == 0)
                return false;
@@ -134,6 +140,7 @@ bool should_fail(struct fault_attr *attr, ssize_t size)
        if (!fail_stacktrace(attr))
                return false;
 
+fail:
        fail_dump(attr);
 
        if (atomic_read(&attr->times) != -1)