Skip to content

Commit e396694

Browse files
liuhangbinkuba-moo
authored andcommitted
tools: ynl: avoid print_field when there is no reply
When request a none support device operation, there will be no reply. In this case, the len(desc) check will always be true, causing print_field to enter an infinite loop and crash the program. Example reproducer: # ethtool.py -c veth0 To fix this, return immediately if there is no reply. Fixes: f3d07b0 ("tools: ynl: ethtool testing tool") Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Link: https://patch.msgid.link/20251024125853.102916-1-liuhangbin@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 855e431 commit e396694

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

tools/net/ynl/pyynl/ethtool.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def print_field(reply, *desc):
4444
Pretty-print a set of fields from the reply. desc specifies the
4545
fields and the optional type (bool/yn).
4646
"""
47+
if not reply:
48+
return
49+
4750
if len(desc) == 0:
4851
return print_field(reply, *zip(reply.keys(), reply.keys()))
4952

0 commit comments

Comments
 (0)