[PATCH nvme-cli] fabrics: fix segfault when -t <transport> is not passed

Sagi Grimberg sagi at grimberg.me
Wed Aug 19 06:31:57 EDT 2020


Need to check if transport was provided before we derefernce
it.

Fixes: 9da606b4afcc ("fabrics: allow traddr to be host name for ip based transports")
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
 fabrics.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fabrics.c b/fabrics.c
index 73bb37529448..c93b752ff142 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -923,7 +923,7 @@ static bool traddr_is_hostname(struct config *cfg)
 {
 	char addrstr[NVMF_TRADDR_SIZE];
 
-	if (!cfg->traddr)
+	if (!cfg->traddr || !cfg->transport)
 		return false;
 	if (strcmp(cfg->transport, "tcp") && strcmp(cfg->transport, "rdma"))
 		return false;
-- 
2.25.1




More information about the Linux-nvme mailing list