]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: plugins/fdp, check endurance group identifier
authorNitesh Shetty <nj.shetty@samsung.com>
Fri, 29 Nov 2024 06:07:16 +0000 (11:37 +0530)
committerDaniel Wagner <wagi@monom.org>
Fri, 13 Dec 2024 09:39:58 +0000 (10:39 +0100)
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@samsung.com>
plugins/fdp/fdp.c

index cac0b2bd728fd54ffdc14feab29c6821f17d92b1..c61706ac47f695c230c582a3a12e93cdbf491a18 100644 (file)
@@ -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,