[PATCH 2/3] nvmet: demote admin cmd parse err msg to debug

Chaitanya Kulkarni chaitanya.kulkarni at wdc.com
Fri Apr 30 02:06:50 BST 2021


Host can send invalid admin commands and flood the target with error
messages. Demote the error message from pr_err() to pr_debug() in
nvmet_parse_admin_cmd() by calling nvmet_report_invlid_opcode(). 

This also removes the duplicate code.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 drivers/nvme/target/admin-cmd.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index d2a26ff3f7b3..f907ec6bd1ab 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -975,10 +975,7 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
 	case nvme_admin_keep_alive:
 		req->execute = nvmet_execute_keep_alive;
 		return 0;
+	default:
+		return nvmet_report_invalid_opcode(req);
 	}
-
-	pr_err("unhandled cmd %d on qid %d\n", cmd->common.opcode,
-	       req->sq->qid);
-	req->error_loc = offsetof(struct nvme_common_command, opcode);
-	return NVME_SC_INVALID_OPCODE | NVME_SC_DNR;
 }
-- 
2.22.1




More information about the Linux-nvme mailing list