printk: fix kmsg_dump_get_buffer length calulations
authorJohn Ogness <john.ogness@linutronix.de>
Wed, 13 Jan 2021 16:44:13 +0000 (17:50 +0106)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jan 2021 10:55:08 +0000 (11:55 +0100)
commitce4d02da78a30e6ba6ed61a745900ae49985ba1e
tree8fe9e0f13eccd1adfec2228c65cd32a2c9856464
parentcf3cca5f1580ce846e36c32db2c125199dca2d86
printk: fix kmsg_dump_get_buffer length calulations

[ Upstream commit 89ccf18f032f26946e2ea6258120472eec6aa745 ]

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: e2ae715d66bf ("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>
kernel/printk/printk.c