Skip to content

Commit ce4d02d

Browse files
jognessgregkh
authored andcommitted
printk: fix kmsg_dump_get_buffer length calulations
[ Upstream commit 89ccf18 ] kmsg_dump_get_buffer() uses @syslog to determine if the syslog prefix should be written to the buffer. However, when calculating the maximum number of records that can fit into the buffer, it always counts the bytes from the syslog prefix. Use @syslog when calculating the maximum number of records that can fit into the buffer. Fixes: e2ae715 ("kmsg - kmsg_dump() use iterator to receive log buffer content") Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Acked-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20210113164413.1599-1-john.ogness@linutronix.de Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent cf3cca5 commit ce4d02d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎kernel/printk/printk.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,7 +3376,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
33763376
while (prb_read_valid_info(prb, seq, &info, &line_count)) {
33773377
if (r.info->seq >= dumper->next_seq)
33783378
break;
3379-
l += get_record_print_text_size(&info, line_count, true, time);
3379+
l += get_record_print_text_size(&info, line_count, syslog, time);
33803380
seq = r.info->seq + 1;
33813381
}
33823382

@@ -3386,7 +3386,7 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
33863386
&info, &line_count)) {
33873387
if (r.info->seq >= dumper->next_seq)
33883388
break;
3389-
l -= get_record_print_text_size(&info, line_count, true, time);
3389+
l -= get_record_print_text_size(&info, line_count, syslog, time);
33903390
seq = r.info->seq + 1;
33913391
}
33923392

0 commit comments

Comments
 (0)