printk: ringbuffer: fix setting state in desc_read()
authorJohn Ogness <john.ogness@linutronix.de>
Mon, 14 Sep 2020 09:48:02 +0000 (11:54 +0206)
committerPetr Mladek <pmladek@suse.com>
Tue, 15 Sep 2020 12:23:37 +0000 (14:23 +0200)
commitce003d67ad521d950687bce7e42e5361022c7d3d
tree0b131518cfd2868d2780a1ddb70f16c30c51d1ef
parente60768311af854734ce2bbfc50f24cff67b54a91
printk: ringbuffer: fix setting state in desc_read()

It is expected that desc_read() will always set at least the
@state_var field. However, if the descriptor is in an inconsistent
state, no fields are set.

Also, the second load of @state_var is not stored in @desc_out and
so might not match the state value that is returned.

Always set the last loaded @state_var into @desc_out, regardless of
the descriptor consistency.

Fixes: b6cf8b3f3312 ("printk: add lockless ringbuffer")
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20200914094803.27365-1-john.ogness@linutronix.de
kernel/printk/printk_ringbuffer.c