Skip to content

Commit

Permalink
nvme: plugins/fdp, check endurance group identifier
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
nj-shetty authored and igaw committed Dec 13, 2024
1 parent 8330814 commit 79b201f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions plugins/fdp/fdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 79b201f

Please sign in to comment.