[patch 114/118] scripts/gdb: fix list_for_each
From: Andrew Morton <akpm@linux-foundation.org>
Date: 2021-02-26 01:22:38
Also in:
mm-commits
From: Andrew Morton <akpm@linux-foundation.org>
Date: 2021-02-26 01:22:38
Also in:
mm-commits
From: George Prekas <redacted> Subject: scripts/gdb: fix list_for_each If the list is uninitialized (next pointer is NULL), list_for_each gets stuck in an infinite loop. Print a message and treat list as empty. Link: https://lkml.kernel.org/r/4ae23bb1-c333-f669-da2d-fa35c4f49018@amazon.com Signed-off-by: George Prekas <redacted> Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com> Cc: Kieran Bingham <kbingham@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- scripts/gdb/linux/lists.py | 5 +++++ 1 file changed, 5 insertions(+)
--- a/scripts/gdb/linux/lists.py~scripts-gdb-fix-list_for_each
+++ a/scripts/gdb/linux/lists.py@@ -27,6 +27,11 @@ def list_for_each(head): raise TypeError("Must be struct list_head not {}" .format(head.type)) + if head['next'] == 0: + gdb.write("list_for_each: Uninitialized list '{}' treated as empty\n" + .format(head.address)) + return + node = head['next'].dereference() while node.address != head.address: yield node.address
_