Commit 668af87f authored by John Ogness's avatar John Ogness Committed by Petr Mladek

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: b6cf8b3f ("printk: add lockless ringbuffer")
Signed-off-by: default avatarJohn Ogness <john.ogness@linutronix.de>
Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
Acked-by: default avatarSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20210113144234.6545-1-john.ogness@linutronix.de
parent b031a684
...@@ -1720,7 +1720,7 @@ static bool copy_data(struct prb_data_ring *data_ring, ...@@ -1720,7 +1720,7 @@ static bool copy_data(struct prb_data_ring *data_ring,
/* Caller interested in the line count? */ /* Caller interested in the line count? */
if (line_count) if (line_count)
*line_count = count_lines(data, data_size); *line_count = count_lines(data, len);
/* Caller interested in the data content? */ /* Caller interested in the data content? */
if (!buf || !buf_size) if (!buf || !buf_size)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment