File 0008-fabrics-avoid-segfault-when-nvme-discover-fails-with.patch of Package nvme-cli.26591
From: Martin George <marting@netapp.com>
Date: Mon, 11 Apr 2022 09:36:20 +0530
Subject: fabrics: avoid segfault when nvme discover fails with the -p option
Git-commit: d49b74393cdbc29e7e092226083341bb9dfa8f6f
References: git-fixes
If the initial discovery controller creation fails while passing
the -p option to the nvme discover (or connect-all) command, it
could lead to the below segfault:
nvme discover -t rdma -w 192.168.1.114 -a 192.168.1.113 -p
Failed to write to /dev/nvme-fabrics: Connection reset by peer
Segmentation fault (core dumped)
Avoid this segfault by checking if the controller created in
__create_discover_ctrl() is valid before proceeding.
Signed-off-by: Martin George <marting@netapp.com>
Acked-by: Daniel Wagner <dwagner@suse.de>
---
fabrics.c | 3 +++
1 file changed, 3 insertions(+)
--- a/fabrics.c
+++ b/fabrics.c
@@ -173,6 +173,9 @@ static nvme_ctrl_t create_discover_ctrl(
nvme_ctrl_t c;
c = __create_discover_ctrl(r, h, cfg, trcfg);
+ if (!c)
+ return NULL;
+
if (!persistent)
return c;