Skip to content

Commit

Permalink
printk_ratelimited(): fix uninitialized spinlock
Browse files Browse the repository at this point in the history
commit d8521fc 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 <[email protected]>
Cc: Joe Perches <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Cc: Sven-Haegar Koch <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
OGAWAHirofumi authored and debian-kernel-patches-to-git committed Apr 3, 2012
1 parent 09ef8de commit 0250331
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,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: */
Expand Down

0 comments on commit 0250331

Please sign in to comment.