Merge remote-tracking branch 'rcu/rcu/next'
[deliverable/linux.git] / include / linux / bug.h
index 292d6a10b0c2683ecbd57858ca069e3dc0bb952e..baff2e8fc8a82792045c3bb0112fb52cead7e6cb 100644 (file)
@@ -121,4 +121,21 @@ static inline enum bug_trap_type report_bug(unsigned long bug_addr,
 }
 
 #endif /* CONFIG_GENERIC_BUG */
+
+/*
+ * Since detected data corruption should stop operation on the affected
+ * structures, this returns false if the corruption condition is found.
+ */
+#define CHECK_DATA_CORRUPTION(condition, fmt, ...)                      \
+       do {                                                             \
+               if (unlikely(condition)) {                               \
+                       if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
+                               pr_err(fmt, ##__VA_ARGS__);              \
+                               BUG();                                   \
+                       } else                                           \
+                               WARN(1, fmt, ##__VA_ARGS__);             \
+                       return false;                                    \
+               }                                                        \
+       } while (0)
+
 #endif /* _LINUX_BUG_H */
This page took 0.02582 seconds and 5 git commands to generate.