aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bug.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/bug.h')
-rw-r--r--include/linux/bug.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/bug.h b/include/linux/bug.h
index 292d6a10b0c2..baff2e8fc8a8 100644
--- a/include/linux/bug.h
+++ b/include/linux/bug.h
@@ -121,4 +121,21 @@ static inline enum bug_trap_type report_bug(unsigned long bug_addr,
121} 121}
122 122
123#endif /* CONFIG_GENERIC_BUG */ 123#endif /* CONFIG_GENERIC_BUG */
124
125/*
126 * Since detected data corruption should stop operation on the affected
127 * structures, this returns false if the corruption condition is found.
128 */
129#define CHECK_DATA_CORRUPTION(condition, fmt, ...) \
130 do { \
131 if (unlikely(condition)) { \
132 if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
133 pr_err(fmt, ##__VA_ARGS__); \
134 BUG(); \
135 } else \
136 WARN(1, fmt, ##__VA_ARGS__); \
137 return false; \
138 } \
139 } while (0)
140
124#endif /* _LINUX_BUG_H */ 141#endif /* _LINUX_BUG_H */