diff --git a/Documentation/nvme-admin-passthru.txt b/Documentation/nvme-admin-passthru.txt index c930e8c76b..f4a6b06e9c 100644 --- a/Documentation/nvme-admin-passthru.txt +++ b/Documentation/nvme-admin-passthru.txt @@ -47,6 +47,7 @@ OPTIONS -O :: --opcode=:: The NVMe opcode to send to the device in the command + Required argument as this param is mandatory. -f :: --flags=:: diff --git a/Documentation/nvme-io-passthru.txt b/Documentation/nvme-io-passthru.txt index fd76bd5cc0..902bf723bf 100644 --- a/Documentation/nvme-io-passthru.txt +++ b/Documentation/nvme-io-passthru.txt @@ -46,6 +46,7 @@ OPTIONS -O :: --opcode=:: The NVMe opcode to send to the device in the command + Required argument as this param is mandatory. -f :: --flags=:: diff --git a/Documentation/nvme-nvme-mi-recv.txt b/Documentation/nvme-nvme-mi-recv.txt index 152bbe67c0..c2df630289 100644 --- a/Documentation/nvme-nvme-mi-recv.txt +++ b/Documentation/nvme-nvme-mi-recv.txt @@ -30,6 +30,7 @@ OPTIONS -O :: --opcode=:: The NVMe-MI opcode to send to the device in the command + Required argument as this param is mandatory. -n :: --namespace-id=:: diff --git a/Documentation/nvme-nvme-mi-send.txt b/Documentation/nvme-nvme-mi-send.txt index 0e80fe7a02..8e356011e9 100644 --- a/Documentation/nvme-nvme-mi-send.txt +++ b/Documentation/nvme-nvme-mi-send.txt @@ -30,6 +30,7 @@ OPTIONS -O :: --opcode=:: The NVMe-MI opcode to send to the device in the command + Required argument as this param is mandatory. -n :: --namespace-id=:: diff --git a/nvme.c b/nvme.c index 5aaa838310..3a37ac122b 100644 --- a/nvme.c +++ b/nvme.c @@ -9123,6 +9123,11 @@ static int passthru(int argc, char **argv, bool admin, return err; } + if (!argconfig_parse_seen(opts, "opcode")) { + nvme_show_error("%s: opcode parameter required", cmd->name); + return -EINVAL; + } + if (cfg.opcode & 0x01) { cfg.write = true; flags = O_RDONLY; @@ -10186,6 +10191,11 @@ static int nvme_mi(int argc, char **argv, __u8 admin_opcode, const char *desc) if (err) return err; + if (!argconfig_parse_seen(opts, "opcode")) { + nvme_show_error("%s: opcode parameter required", *argv); + return -EINVAL; + } + if (admin_opcode == nvme_admin_nvme_mi_send) { flags = O_RDONLY; fd = STDIN_FILENO;