Re: [PATCH] printk_ringbuffer: Fix space_used() when blk_lpos->next overflows

From: Petr Mladek

Date: Tue Oct 27 2026 - 11:15:55 EST


On Sun 2026-10-04 15:57:55, Wang Wensheng wrote:
> Since commit 67e1b0052f6b ("printk_ringbuffer: don't needlessly wrap data
> blocks around") blk_lpos is treated as not wrapped when blk_lpos->next
> overflows to the start of data_ring. We use the indices of blk_lpos->next
> and blk_lpos->start to calculate the size of the data_block. This computes
> zero minus a small positive value, resulting in underflow and an
> unexpectedly large value. Simply using the original lpos with wrap-counts
> solves the problem.
>
> Fixes: 67e1b0052f6b ("printk_ringbuffer: don't needlessly wrap data blocks around")
> Signed-off-by: Wang Wensheng <wsw9603@xxxxxxx>

JFYI, the patch has been committed into printk/linux.git,
branch for-7.4-fixups.

Best Regards,
Petr