X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=include%2Flinux%2Fbug.h;h=baff2e8fc8a82792045c3bb0112fb52cead7e6cb;hb=72b5d28ed8ab410cd029fc6e7536b904c0b9f4a0;hp=292d6a10b0c2683ecbd57858ca069e3dc0bb952e;hpb=5e10a8a0a7f312b7126a43b6b60a69a2d077c734;p=deliverable%2Flinux.git 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, } #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 */