summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2010-05-24 14:33:11 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-04 09:49:19 -0800
commit3a86cda406c00df3a1c207ba26406847d8e53bba (patch)
tree05773caf49e796678fd2ef4cef3875b946518ed2
parent3aee4081eee4987bbf2dd00c7267a8b2ea7386a0 (diff)
downloadlwn-3a86cda406c00df3a1c207ba26406847d8e53bba.tar.gz
lwn-3a86cda406c00df3a1c207ba26406847d8e53bba.zip
printk_ratelimited(): fix uninitialized spinlock
commit d8521fcc5e0ad3e79bbc4231bb20a6cdc2b50164 upstream. ratelimit_state initialization of printk_ratelimited() seems broken. This fixes it by using DEFINE_RATELIMIT_STATE() to initialize spinlock properly. Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Cc: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Sven-Haegar Koch <haegar@sdinet.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--include/linux/kernel.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index f963c1bdcbee..9acb92d8fb06 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -411,14 +411,13 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
* no local ratelimit_state used in the !PRINTK case
*/
#ifdef CONFIG_PRINTK
-#define printk_ratelimited(fmt, ...) ({ \
- static struct ratelimit_state _rs = { \
- .interval = DEFAULT_RATELIMIT_INTERVAL, \
- .burst = DEFAULT_RATELIMIT_BURST, \
- }; \
- \
- if (__ratelimit(&_rs)) \
- printk(fmt, ##__VA_ARGS__); \
+#define printk_ratelimited(fmt, ...) ({ \
+ static DEFINE_RATELIMIT_STATE(_rs, \
+ DEFAULT_RATELIMIT_INTERVAL, \
+ DEFAULT_RATELIMIT_BURST); \
+ \
+ if (__ratelimit(&_rs)) \
+ printk(fmt, ##__VA_ARGS__); \
})
#else
/* No effect, but we still get type checking even in the !PRINTK case: */