]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tools: ynl: avoid print_field when there is no reply
authorHangbin Liu <liuhangbin@gmail.com>
Fri, 24 Oct 2025 12:58:53 +0000 (12:58 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:36:42 +0000 (15:36 -0500)
[ Upstream commit e3966940559d52aa1800a008dcfeec218dd31f88 ]

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@gmail.com>
Link: https://patch.msgid.link/20251024125853.102916-1-liuhangbin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/net/ynl/pyynl/ethtool.py

index cab6b576c8762e0bb4e6ff730c7cf21cd9e1fa56..87bb56108005660ad7f317e1ca114a75a8c865e6 100755 (executable)
@@ -45,6 +45,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()))