linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: George Prekas <prekageo@amazon.com>, linux-kernel@vger.kernel.org
Cc: Kieran Bingham <kbingham@kernel.org>
Subject: Re: [PATCH] scripts/gdb: fix list_for_each
Date: Tue, 22 Sep 2020 16:32:02 +0200	[thread overview]
Message-ID: <2516a051-306f-670b-1f9e-d46fc577c7f8@siemens.com> (raw)
In-Reply-To: <3b382958-9f1d-a3d2-a239-09ba084227e6@amazon.com>

On 22.09.20 16:28, George Prekas wrote:
> If the next pointer is NULL, list_for_each gets stuck in an infinite
> loop.
> 
> Signed-off-by: George Prekas <prekageo@amazon.com>
> ---
>   scripts/gdb/linux/lists.py | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py
> index c487ddf09d38..424a91c1aa8b 100644
> --- a/scripts/gdb/linux/lists.py
> +++ b/scripts/gdb/linux/lists.py
> @@ -27,6 +27,8 @@ def list_for_each(head):
>           raise TypeError("Must be struct list_head not {}"
>                              .format(head.type))
> 
> +    if head['next'] == 0:
> +        return
>       node = head['next'].dereference()
>       while node.address != head.address:
>           yield node.address

Obviously, infinite loops are bad and should be avoided. But NULL is 
bug, isn't it? Shouldn't we report such a corruption?

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

  reply	other threads:[~2020-09-22 14:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22 14:28 [PATCH] scripts/gdb: fix list_for_each George Prekas
2020-09-22 14:32 ` Jan Kiszka [this message]
2020-09-22 17:17   ` Prekas, George
2020-09-22 19:11     ` Kieran Bingham
2020-09-23 13:13       ` George Prekas
2020-09-23 21:17         ` Kieran Bingham

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=2516a051-306f-670b-1f9e-d46fc577c7f8@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=kbingham@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=prekageo@amazon.com \
    /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).