[PATCH 2/2] nvmet: fix return value check in auth receive
Hannes Reinecke
hare at suse.de
Mon Jul 18 23:51:45 PDT 2022
On 7/19/22 01:12, Chaitanya Kulkarni wrote:
> 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.
>
> Reported-by: Dan Carpenter <dan.carpenter at oracle.com>
> Signed-off-by: Chaitanya Kulkarni <kch at nvidia.com>
> ---
> drivers/nvme/target/fabrics-cmd-auth.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/target/fabrics-cmd-auth.c b/drivers/nvme/target/fabrics-cmd-auth.c
> index f1c9c2f51afb..45056e204dde 100644
> --- a/drivers/nvme/target/fabrics-cmd-auth.c
> +++ b/drivers/nvme/target/fabrics-cmd-auth.c
> @@ -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;
Reviewed-by: Hannes Reinecke <hare at suse.de>
Cheers,
Hannes
More information about the Linux-nvme
mailing list