Skip to content

Commit

Permalink
ring_buffer: Do not deactivate non-existant pages
Browse files Browse the repository at this point in the history
rb_head_page_deactivate() expects cpu_buffer to contain a valid list of
->pages, so verify that the list is actually present before calling it.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Link: https://lkml.kernel.org/r/20221114143129.3534443-1-d-tatianin@yandex-team.ru

Cc: stable@vger.kernel.org
Fixes: 77ae365 ("ring-buffer: make lockless")
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
  • Loading branch information
Daniil Tatianin authored and Steven Rostedt (Google) committed Nov 17, 2022
1 parent bcea02b commit 56f4ca0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1802,9 +1802,9 @@ static void rb_free_cpu_buffer(struct ring_buffer_per_cpu *cpu_buffer)

free_buffer_page(cpu_buffer->reader_page);

rb_head_page_deactivate(cpu_buffer);

if (head) {
rb_head_page_deactivate(cpu_buffer);

list_for_each_entry_safe(bpage, tmp, head, list) {
list_del_init(&bpage->list);
free_buffer_page(bpage);
Expand Down

0 comments on commit 56f4ca0

Please sign in to comment.