lkml.org 
[lkml]   [2020]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] scripts/gdb: fix list_for_each
From
Date
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

\
 
 \ /
  Last update: 2020-09-22 16:40    [W:0.069 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site