提交 db7fbf49 编写于 作者: G George Prekas 提交者: Linus Torvalds

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.comSigned-off-by: NGeorge Prekas <prekageo@amazon.com>
Reviewed-by: NJan Kiszka <jan.kiszka@siemens.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 3d2fc4c0
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册