Skip to content

Commit 668af87

Browse files
jognesspmladek
authored andcommitted
printk: ringbuffer: fix line counting
Counting text lines in a record simply involves counting the number of newline characters (+1). However, it is searching the full data block for newline characters, even though the text data can be (and often is) a subset of that area. Since the extra area in the data block was never initialized, the result is that extra newlines may be seen and counted. Restrict newline searching to the text data length. Fixes: b6cf8b3 ("printk: add lockless ringbuffer") Signed-off-by: John Ogness <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Acked-by: Sergey Senozhatsky <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b031a68 commit 668af87

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/printk/printk_ringbuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,7 @@ static bool copy_data(struct prb_data_ring *data_ring,
17201720

17211721
/* Caller interested in the line count? */
17221722
if (line_count)
1723-
*line_count = count_lines(data, data_size);
1723+
*line_count = count_lines(data, len);
17241724

17251725
/* Caller interested in the data content? */
17261726
if (!buf || !buf_size)

0 commit comments

Comments
 (0)