Skip to contentSkip to conversation

tools: ynl: avoid print_field when there is no reply

PATCH Applied Hangbin Liu 2 participants 2 messages Oct 24, 2025 – Oct 28, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 tools/net/ynl/pyynl/ethtool.py | 3 +++
 1 file changed, 3 insertions(+)
tools/net/ynl/pyynl/ethtool.py +3 -0
index 9b523cbb3568..fd0f6b8d54d1 100755
@@ -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()))
 
Signature · 1 line
2.50.1
#1 lore raw
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Fri, 24 Oct 2025 12:58:53 +0000 you wrote:

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.

[...]

Here is the summary with links:
- [net] tools: ynl: avoid print_field when there is no reply

    https://git.kernel.org/netdev/net/c/e3966940559d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html