File 0014-Input-expects-device-name-without-dev.patch of Package nvme-cli.26590
From: Eric Curtin <ericcurtin17@gmail.com>
Date: Wed, 10 Feb 2021 00:01:59 +0000
Subject: Input expects device name without /dev
References: bsc#1191935
Git-commit: dcfe0156360deaefa26b1d00053a791eefe397d1
But don't segfault if user gets this incorrect, instead provide helpful
info.
---
fabrics.c | 5 +++++
nvme-topology.c | 4 +++-
2 files changed, 8 insertions(+), 1 deletion(-)
--- a/fabrics.c
+++ b/fabrics.c
@@ -306,6 +306,11 @@ static bool ctrl_matches_connectargs(cha
return found;
addr = nvme_get_ctrl_attr(path, "address");
+ if (!addr) {
+ fprintf(stderr, "nvme_get_ctrl_attr failed\n");
+ return found;
+ }
+
cargs.subsysnqn = nvme_get_ctrl_attr(path, "subsysnqn");
cargs.transport = nvme_get_ctrl_attr(path, "transport");
cargs.traddr = parse_conn_arg(addr, ' ', conarg_traddr);
--- a/nvme-topology.c
+++ b/nvme-topology.c
@@ -60,8 +60,10 @@ char *nvme_get_ctrl_attr(char *path, con
goto err_free_path;
fd = open(attrpath, O_RDONLY);
- if (fd < 0)
+ if (fd < 0) {
+ fprintf(stderr, "Failed to open %s: %s\n", attrpath, strerror(errno));
goto err_free_value;
+ }
ret = read(fd, value, 1024);
if (ret < 0) {