From: Martin George Date: Mon, 18 Apr 2022 07:22:37 +0000 (+0530) Subject: fabrics: avoid segfault if transport type is omitted X-Git-Tag: v2.1-rc0~64^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=565c8d2da873e143b343bdf42ea71e9aa9636efa;p=users%2Fsagi%2Fnvme-cli.git fabrics: avoid segfault if transport type is omitted 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 --- diff --git a/fabrics.c b/fabrics.c index f512ffab..b5537859 100644 --- a/fabrics.c +++ b/fabrics.c @@ -478,6 +478,8 @@ static nvme_ctrl_t lookup_discover_ctrl(nvme_root_t r, struct tr_config *trcfg) 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 */