File 0009-fabrics-avoid-segfault-if-transport-type-is-omitted.patch of Package nvme-cli.26914
From: Martin George <marting@netapp.com>
Date: Mon, 18 Apr 2022 12:52:37 +0530
Subject: fabrics: avoid segfault if transport type is omitted
Git-commit: 565c8d2da873e143b343bdf42ea71e9aa9636efa
References: git-fixes
A nvme discover or connect-all would currently end up in a
segfault if the transport type is omitted as shown below:
nvme discover -w 192.168.1.114 -a 192.168.1.160
Segmentation fault (core dumped)
Avoid this segfault by checking if the transport type is
available before proceeding in get_default_trsvcid().
Signed-off-by: Martin George <marting@netapp.com>
Acked-by: Daniel Wagner <dwagner@suse.de>
---
fabrics.c | 2 ++
1 file changed, 2 insertions(+)
--- a/fabrics.c
+++ b/fabrics.c
@@ -481,6 +481,8 @@ static nvme_ctrl_t lookup_discover_ctrl(
static char *get_default_trsvcid(const char *transport,
bool discovery_ctrl)
{
+ if (!transport)
+ return NULL;
if (!strcmp(transport, "tcp")) {
if (discovery_ctrl) {
/* Default port for NVMe/TCP discovery controllers */