diff options
author | Daniel Thompson <daniel.thompson@linaro.org> | 2015-03-18 16:47:08 +0000 |
---|---|---|
committer | Daniel Thompson <daniel.thompson@linaro.org> | 2015-09-13 09:22:45 +0100 |
commit | 093b1974fd19fada56931748215e3c4bbc4cfeea (patch) | |
tree | 3e1f486a830e74eb6139cce8f332f033178d8028 | |
parent | ac398716ab5c54732d6d0b11402ee78ab7a99ea6 (diff) |
bug: Recursion avoidance for WARN_ONCE() and friends
Currently WARN_ONCE() and similar macros set __warned *after* calling
the underlying macro. This risks infinite recursion if WARN_ONCE() is
used to implement sanity tests in any code that can be called by printk.
This can be fixed by restructuring the macros to set __warned before
calling further macros.
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
-rw-r--r-- | include/asm-generic/bug.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 630dd2372238..f8c8a819c563 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -110,9 +110,10 @@ extern void warn_slowpath_null(const char *file, const int line); static bool __section(.data.unlikely) __warned; \ int __ret_warn_once = !!(condition); \ \ - if (unlikely(__ret_warn_once)) \ - if (WARN_ON(!__warned)) \ - __warned = true; \ + if (unlikely(__ret_warn_once) && !__warned) { \ + __warned = true; \ + WARN_ON(true); \ + } \ unlikely(__ret_warn_once); \ }) @@ -120,9 +121,10 @@ extern void warn_slowpath_null(const char *file, const int line); static bool __section(.data.unlikely) __warned; \ int __ret_warn_once = !!(condition); \ \ - if (unlikely(__ret_warn_once)) \ - if (WARN(!__warned, format)) \ - __warned = true; \ + if (unlikely(__ret_warn_once) && !__warned) { \ + __warned = true; \ + WARN(true, format); \ + } \ unlikely(__ret_warn_once); \ }) @@ -130,9 +132,10 @@ extern void warn_slowpath_null(const char *file, const int line); static bool __section(.data.unlikely) __warned; \ int __ret_warn_once = !!(condition); \ \ - if (unlikely(__ret_warn_once)) \ - if (WARN_TAINT(!__warned, taint, format)) \ - __warned = true; \ + if (unlikely(__ret_warn_once) && !__warned) { \ + __warned = true; \ + WARN_TAINT(true, taint, format); \ + } \ unlikely(__ret_warn_once); \ }) |