linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: George Prekas <prekageo@amazon.com>
To: Jan Kiszka <jan.kiszka@siemens.com>,
	Kieran Bingham <kbingham@kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH v2] scripts/gdb: fix list_for_each
Date: Thu, 24 Sep 2020 09:20:56 -0500	[thread overview]
Message-ID: <4ae23bb1-c333-f669-da2d-fa35c4f49018@amazon.com> (raw)

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.

Signed-off-by: George Prekas <prekageo@amazon.com>
---
  scripts/gdb/linux/lists.py | 5 +++++
  1 file changed, 5 insertions(+)

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
-- 
2.16.6


             reply	other threads:[~2020-09-24 14:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-24 14:20 George Prekas [this message]
2021-01-05 16:51 ` [PATCH v2] scripts/gdb: fix list_for_each George Prekas
2021-01-05 19:08   ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ae23bb1-c333-f669-da2d-fa35c4f49018@amazon.com \
    --to=prekageo@amazon.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kbingham@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).