Skip to contentSkip to conversation

nvmet: type missmatch fixes for nvmet-auth

PATCH In review Chaitanya Kulkarni 4 participants 7 messages Jul 18, 2022 – Jul 21, 2022

Subsystems (3)
lore
Share & tools
lore

Chaitanya Kulkarni

author maintainer
#0 lore raw

cover nvmet: type missmatch fixes for nvmet-auth

Hi,

Couple of type mismatch fixes for nvmet-auth reported by Dan Carpenter.

-ck

Chaitanya Kulkarni (2):
nvmet: fix return value check in auth send
nvmet: fix return value check in auth receive

 drivers/nvme/target/fabrics-cmd-auth.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
Signature · 1 line
2.29.0
author maintainer
#1 lore raw

PATCH 1/2 nvmet: fix return value check in auth send

nvmet_setup_auth() return type is int and currently it uses status variable that is of type u16 in nvmet_execute_auth_send().

Catch the return value of nvmet_setup_auth() into int and set the NVME_SC_INTERNAL as status variable before we jump to error.

---
 drivers/nvme/target/fabrics-cmd-auth.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvme/target/fabrics-cmd-auth.c +4 -2
index cc56e8c821ce..f1c9c2f51afb 100644
@@ -247,8 +247,10 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
 			pr_debug("%s: ctrl %d qid %d reset negotiation\n", __func__,
 				 ctrl->cntlid, req->sq->qid);
 			if (!req->sq->qid) {
-				status = nvmet_setup_auth(ctrl);
-				if (status < 0) {
+				int ret = nvmet_setup_auth(ctrl);
+
+				if (ret < 0) {
+					status = NVME_SC_INTERNAL;
 					pr_err("ctrl %d qid 0 failed to setup"
 					       "re-authentication",
 					       ctrl->cntlid);
Signature · 1 line
2.29.0
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] nvmet: fix return value check in auth send

Quoted 19 lines · Chaitanya Kulkarni

nvmet_setup_auth() return type is int and currently it uses status variable that is of type u16 in nvmet_execute_auth_send().

Catch the return value of nvmet_setup_auth() into int and set the NVME_SC_INTERNAL as status variable before we jump to error.

---
  drivers/nvme/target/fabrics-cmd-auth.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvme/target/fabrics-cmd-auth.c +0 -0
index cc56e8c821ce..f1c9c2f51afb 100644
@@ -247,8 +247,10 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
  			pr_debug("%s: ctrl %d qid %d reset negotiation\n", __func__,
  				 ctrl->cntlid, req->sq->qid);

drivers/nvme/target/fabrics-cmd-auth.c void nvmet_execute_auth_send(struct nvmet_req *req) · line 256

Quoted 10 lines
drivers/nvme/target/fabrics-cmd-auth.c +4 -2
  			if (!req->sq->qid) {
-				status = nvmet_setup_auth(ctrl);
-				if (status < 0) {
+				int ret = nvmet_setup_auth(ctrl);
+
+				if (ret < 0) {
+					status = NVME_SC_INTERNAL;
  					pr_err("ctrl %d qid 0 failed to setup"
  					       "re-authentication",
  					       ctrl->cntlid);

Cheers,

Hannes

author maintainer
#4 lore raw

PATCH 2/2 nvmet: fix return value check in auth receive

In reply to Chaitanya Kulkarni

nvmet_auth_challenge() return type is int and currently it uses status variable that is of type u16 in nvmet_execute_auth_receive().

Catch the return value of nvmet_auth_challenge() into int and set the NVME_SC_INTERNAL as status variable before we jump to error.

---
 drivers/nvme/target/fabrics-cmd-auth.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvme/target/fabrics-cmd-auth.c +3 -2
index f1c9c2f51afb..45056e204dde 100644
@@ -486,8 +486,9 @@ void nvmet_execute_auth_receive(struct nvmet_req *req)
 		 ctrl->cntlid, req->sq->qid, req->sq->dhchap_step);
 	switch (req->sq->dhchap_step) {
 	case NVME_AUTH_DHCHAP_MESSAGE_CHALLENGE:
-		status = nvmet_auth_challenge(req, d, al);
-		if (status < 0) {
+		int ret = nvmet_auth_challenge(req, d, al);
+
+		if (ret < 0) {
 			pr_warn("ctrl %d qid %d: challenge error (%d)\n",
 				ctrl->cntlid, req->sq->qid, status);
 			status = NVME_SC_INTERNAL;
Signature · 1 line
2.29.0
maintainer Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] nvmet: fix return value check in auth receive

Quoted 18 lines · Chaitanya Kulkarni

nvmet_auth_challenge() return type is int and currently it uses status variable that is of type u16 in nvmet_execute_auth_receive().

Catch the return value of nvmet_auth_challenge() into int and set the NVME_SC_INTERNAL as status variable before we jump to error.

---
  drivers/nvme/target/fabrics-cmd-auth.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvme/target/fabrics-cmd-auth.c +0 -0
index f1c9c2f51afb..45056e204dde 100644
@@ -486,8 +486,9 @@ void nvmet_execute_auth_receive(struct nvmet_req *req)
  		 ctrl->cntlid, req->sq->qid, req->sq->dhchap_step);

drivers/nvme/target/fabrics-cmd-auth.c void nvmet_execute_auth_receive(struct nvmet_req *req) · line 494

Quoted 10 lines
drivers/nvme/target/fabrics-cmd-auth.c +3 -2
  	switch (req->sq->dhchap_step) {
  	case NVME_AUTH_DHCHAP_MESSAGE_CHALLENGE:
-		status = nvmet_auth_challenge(req, d, al);
-		if (status < 0) {
+		int ret = nvmet_auth_challenge(req, d, al);
+
+		if (ret < 0) {
  			pr_warn("ctrl %d qid %d: challenge error (%d)\n",
  				ctrl->cntlid, req->sq->qid, status);
  			status = NVME_SC_INTERNAL;

Cheers,

Hannes