* [PATCH v2] scripts/gdb: fix list_for_each
@ 2020-09-24 14:20 George Prekas
2021-01-05 16:51 ` George Prekas
0 siblings, 1 reply; 3+ messages in thread
From: George Prekas @ 2020-09-24 14:20 UTC (permalink / raw)
To: Jan Kiszka, Kieran Bingham; +Cc: linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] scripts/gdb: fix list_for_each
2020-09-24 14:20 [PATCH v2] scripts/gdb: fix list_for_each George Prekas
@ 2021-01-05 16:51 ` George Prekas
2021-01-05 19:08 ` Jan Kiszka
0 siblings, 1 reply; 3+ messages in thread
From: George Prekas @ 2021-01-05 16:51 UTC (permalink / raw)
To: Jan Kiszka, Kieran Bingham; +Cc: linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] scripts/gdb: fix list_for_each
2021-01-05 16:51 ` George Prekas
@ 2021-01-05 19:08 ` Jan Kiszka
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kiszka @ 2021-01-05 19:08 UTC (permalink / raw)
To: George Prekas, Kieran Bingham, Andrew Morton; +Cc: linux-kernel
On 05.01.21 17:51, George Prekas wrote:
> 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!
Same to you!
>
> Any updates on this?
>
Sorry, slipped through.
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Andrew, please pick this up.
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-05 19:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24 14:20 [PATCH v2] scripts/gdb: fix list_for_each George Prekas
2021-01-05 16:51 ` George Prekas
2021-01-05 19:08 ` Jan Kiszka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®