[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251024125853.102916-1-liuhangbin@gmail.com>
Date: Fri, 24 Oct 2025 12:58:53 +0000
From: Hangbin Liu <liuhangbin@...il.com>
To: netdev@...r.kernel.org
Cc: Donald Hunter <donald.hunter@...il.com>,
Jakub Kicinski <kuba@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>,
Jan Stancek <jstancek@...hat.com>,
"Matthieu Baerts (NGI0)" <matttbe@...nel.org>,
Asbjørn Sloth Tønnesen <ast@...erby.net>,
Stanislav Fomichev <sdf@...ichev.me>,
Hangbin Liu <liuhangbin@...il.com>
Subject: [PATCH net] 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: f3d07b02b2b8 ("tools: ynl: ethtool testing tool")
Signed-off-by: Hangbin Liu <liuhangbin@...il.com>
---
tools/net/ynl/pyynl/ethtool.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/net/ynl/pyynl/ethtool.py b/tools/net/ynl/pyynl/ethtool.py
index 9b523cbb3568..fd0f6b8d54d1 100755
--- a/tools/net/ynl/pyynl/ethtool.py
+++ b/tools/net/ynl/pyynl/ethtool.py
@@ -44,6 +44,9 @@ def print_field(reply, *desc):
Pretty-print a set of fields from the reply. desc specifies the
fields and the optional type (bool/yn).
"""
+ if not reply:
+ return
+
if len(desc) == 0:
return print_field(reply, *zip(reply.keys(), reply.keys()))
--
2.50.1
Powered by blists - more mailing lists