]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: Fix parameter limit range
authorSteven Seungcheol Lee <sc108.lee@samsung.com>
Wed, 15 Mar 2023 05:40:30 +0000 (14:40 +0900)
committerDaniel Wagner <wagi@monom.org>
Wed, 15 Mar 2023 09:10:41 +0000 (10:10 +0100)
3 Bits - Max value 7
SEL : Bits [10:08] of Get Features Command Dword 10

4 Bits - Max value 15
OWPASS : Bits [07:04] of Sanitize – Command Dword 10

7 Bits - Max value 127
LSP : Bits [14:08] of Get Log Page Command Dword 10
UUID Index : Bits [06:00] of Get Log Page, Get Features, Set Features Command Dword 14

Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
nvme.c

diff --git a/nvme.c b/nvme.c
index a9272408d6f481934b3c5d1e219c36eec3b1870f..94bdca7bf35f3b5632a36cb48f3e97a5b892d11a 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -1815,7 +1815,7 @@ static int get_boot_part_log(int argc, char **argv, struct command *cmd, struct
                goto close_dev;
        }
 
-       if (cfg.lsp > 128) {
+       if (cfg.lsp > 127) {
                fprintf(stderr, "invalid lsp param: %u\n", cfg.lsp);
                err = -1;
                goto close_dev;
@@ -2263,13 +2263,13 @@ static int get_log(int argc, char **argv, struct command *cmd, struct plugin *pl
                goto close_dev;
        }
 
-       if (cfg.lsp > 128) {
+       if (cfg.lsp > 127) {
                fprintf(stderr, "invalid lsp param\n");
                err = -EINVAL;
                goto close_dev;
        }
 
-       if (cfg.uuid_index > 128) {
+       if (cfg.uuid_index > 127) {
                fprintf(stderr, "invalid uuid index param\n");
                err = -EINVAL;
                goto close_dev;
@@ -4711,13 +4711,13 @@ static int get_feature(int argc, char **argv, struct command *cmd,
                }
        }
 
-       if (cfg.sel > 8) {
+       if (cfg.sel > 7) {
                fprintf(stderr, "invalid 'select' param:%d\n", cfg.sel);
                err = -EINVAL;
                goto close_dev;
        }
 
-       if (cfg.uuid_index > 128) {
+       if (cfg.uuid_index > 127) {
                fprintf(stderr, "invalid uuid index param: %u\n", cfg.uuid_index);
                err = -1;
                goto close_dev;
@@ -5244,8 +5244,8 @@ static int sanitize(int argc, char **argv, struct command *cmd, struct plugin *p
        }
 
        if (sanact == NVME_SANITIZE_SANACT_START_OVERWRITE) {
-               if (cfg.owpass > 16) {
-                       fprintf(stderr, "OWPASS out of range [0-16]\n");
+               if (cfg.owpass > 15) {
+                       fprintf(stderr, "OWPASS out of range [0-15]\n");
                        err = -EINVAL;
                        goto close_dev;
                }
@@ -5899,7 +5899,7 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin
                goto close_dev;
        }
 
-       if (cfg.uuid_index > 128) {
+       if (cfg.uuid_index > 127) {
                fprintf(stderr, "invalid uuid index param: %u\n", cfg.uuid_index);
                err = -1;
                goto close_dev;