[PATCH nvme-cli] nvme: plugins/fdp, check endurance group identifier

Nitesh Shetty nj.shetty at samsung.com
Thu Nov 28 22:07:16 PST 2024


For FDP options such as stats and events, default endurance identifier 0
is used which results in error.
This patch returns error for missing endurance group identifier from
user.

Signed-off-by: Nitesh Shetty <nj.shetty at samsung.com>
---
 plugins/fdp/fdp.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/plugins/fdp/fdp.c b/plugins/fdp/fdp.c
index cac0b2bd..c61706ac 100644
--- a/plugins/fdp/fdp.c
+++ b/plugins/fdp/fdp.c
@@ -215,6 +215,12 @@ static int fdp_stats(int argc, char **argv, struct command *cmd, struct plugin *
 	if (cfg.raw_binary)
 		flags = BINARY;
 
+	if (!cfg.egid) {
+		fprintf(stderr, "endurance group identifier required\n");
+		err = -EINVAL;
+		goto out;
+	}
+
 	memset(&stats, 0x0, sizeof(stats));
 
 	err = nvme_get_log_fdp_stats(dev->direct.fd, cfg.egid, 0, sizeof(stats), &stats);
@@ -276,6 +282,12 @@ static int fdp_events(int argc, char **argv, struct command *cmd, struct plugin
 	if (cfg.raw_binary)
 		flags = BINARY;
 
+	if (!cfg.egid) {
+		fprintf(stderr, "endurance group identifier required\n");
+		err = -EINVAL;
+		goto out;
+	}
+
 	memset(&events, 0x0, sizeof(events));
 
 	err = nvme_get_log_fdp_events(dev->direct.fd, cfg.egid,
-- 
2.34.1




More information about the Linux-nvme mailing list