Skip to content

Commit d8521fc

Browse files
OGAWAHirofumitorvalds
authored andcommitted
printk_ratelimited(): fix uninitialized spinlock
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>
1 parent fa1f68d commit d8521fc

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

‎include/linux/kernel.h‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -424,14 +424,13 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
424424
* no local ratelimit_state used in the !PRINTK case
425425
*/
426426
#ifdef CONFIG_PRINTK
427-
#define printk_ratelimited(fmt, ...) ({ \
428-
static struct ratelimit_state _rs = { \
429-
.interval = DEFAULT_RATELIMIT_INTERVAL, \
430-
.burst = DEFAULT_RATELIMIT_BURST, \
431-
}; \
432-
\
433-
if (__ratelimit(&_rs)) \
434-
printk(fmt, ##__VA_ARGS__); \
427+
#define printk_ratelimited(fmt, ...) ({ \
428+
static DEFINE_RATELIMIT_STATE(_rs, \
429+
DEFAULT_RATELIMIT_INTERVAL, \
430+
DEFAULT_RATELIMIT_BURST); \
431+
\
432+
if (__ratelimit(&_rs)) \
433+
printk(fmt, ##__VA_ARGS__); \
435434
})
436435
#else
437436
/* No effect, but we still get type checking even in the !PRINTK case: */

0 commit comments

Comments
 (0)