File 0016-fabrics-nvme-config-modify-depends-on-n-and-t-argume.patch of Package nvme-cli.26914

From: Daniel Wagner <dwagner@suse.de>
Date: Thu, 29 Sep 2022 11:28:50 +0200
Subject: fabrics: nvme config --modify depends on -n and -t argument
Git-commit: 1021863e5daa866327cd44d9caf0743b254e6d12
References: bsc#1203204 bsc#1203163

In order to be able to modify a config we need to look it up
first. The nvme_lookup_subsystem() call will crash if we don't
provide a NQN.

The transport is needed to be able lookup a controller.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 fabrics.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fabrics.c b/fabrics.c
index 43ca5f422d3d..6cf70be7e678 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -1134,6 +1134,18 @@ int nvmf_config(const char *desc, int argc, char **argv)
 		nvme_subsystem_t s;
 		nvme_ctrl_t c;
 
+		if (!subsysnqn) {
+			fprintf(stderr,
+				"required argument [--nqn | -n] needed with --modify\n");
+			return -EINVAL;
+		}
+
+		if (!transport) {
+			fprintf(stderr,
+				"required argument [--transport | -t] needed with --modify\n");
+			return EINVAL;
+		}
+
 		if (!hostnqn)
 			hostnqn = hnqn = nvmf_hostnqn_from_file();
 		if (!hostid && hnqn)
-- 
2.38.1

openSUSE Build Service is sponsored by