From 63dcb68c648e2f71c4c5637b4c6ad9a3e37812b5 Mon Sep 17 00:00:00 2001 From: Steven Seungcheol Lee Date: Wed, 15 Mar 2023 14:40:30 +0900 Subject: [PATCH] nvme: Fix parameter limit range MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- nvme.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/nvme.c b/nvme.c index a9272408..94bdca7b 100644 --- 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; -- 2.50.1