提交 a118ff66 编写于 作者: P Paolo Pisati 提交者: David S. Miller

selftests: net: devlink_port_split: check devlink returned an element before dereferencing it

And thus avoid a Python stacktrace:

~/linux/tools/testing/selftests/net$ ./devlink_port_split.py
Traceback (most recent call last):
  File "/home/linux/tools/testing/selftests/net/./devlink_port_split.py",
line 277, in <module> main()
  File "/home/linux/tools/testing/selftests/net/./devlink_port_split.py",
line 242, in main
    dev = list(devs.keys())[0]
IndexError: list index out of range
Signed-off-by: NPaolo Pisati <paolo.pisati@canonical.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 b856150c
......@@ -239,6 +239,9 @@ def main(cmdline=None):
assert stderr == ""
devs = json.loads(stdout)['dev']
if len(devs.keys()) == 0:
print("no devlink device found")
sys.exit(1)
dev = list(devs.keys())[0]
cmd = "devlink dev show %s" % dev
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册