Skip to content

Commit 79b201f

Browse files
nj-shettyigaw
authored andcommitted
nvme: plugins/fdp, check endurance group identifier
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 <[email protected]>
1 parent 8330814 commit 79b201f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

plugins/fdp/fdp.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,12 @@ static int fdp_stats(int argc, char **argv, struct command *cmd, struct plugin *
215215
if (cfg.raw_binary)
216216
flags = BINARY;
217217

218+
if (!cfg.egid) {
219+
fprintf(stderr, "endurance group identifier required\n");
220+
err = -EINVAL;
221+
goto out;
222+
}
223+
218224
memset(&stats, 0x0, sizeof(stats));
219225

220226
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
276282
if (cfg.raw_binary)
277283
flags = BINARY;
278284

285+
if (!cfg.egid) {
286+
fprintf(stderr, "endurance group identifier required\n");
287+
err = -EINVAL;
288+
goto out;
289+
}
290+
279291
memset(&events, 0x0, sizeof(events));
280292

281293
err = nvme_get_log_fdp_events(dev->direct.fd, cfg.egid,

0 commit comments

Comments
 (0)