aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Prekas <[email protected]>2021-02-25 17:22:34 -0800
committerLinus Torvalds <[email protected]>2021-02-26 09:41:05 -0800
commitdb7fbf492d94a0b59d8f85b3184231662586dea9 (patch)
treeadfd16adb5fc0ad46a05fb60f8753ff80ae0232c
parent3d2fc4c082448e9c05792f9b2a11c1d5db408b85 (diff)
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/[email protected] Signed-off-by: George Prekas <[email protected]> Reviewed-by: Jan Kiszka <[email protected]> Cc: Kieran Bingham <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--scripts/gdb/linux/lists.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py
index c487ddf09d38..bae4d70b7eae 100644
--- a/scripts/gdb/linux/lists.py
+++ b/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