lkml.org 
[lkml]   [2021]   [Jan]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] scripts/gdb: fix list_for_each
From
Date
On 9/24/2020 9:20 AM, George Prekas wrote:
> 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

Happy New Year!

Any updates on this?

Thanks,
George

\
 
 \ /
  Last update: 2021-01-05 17:53    [W:0.061 / U:0.348 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site