]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Revert "nvmet-tcp: Don't free SQ on authentication success"
authorAlistair Francis <alistair.francis@wdc.com>
Fri, 17 Apr 2026 00:48:08 +0000 (10:48 +1000)
committerKeith Busch <kbusch@kernel.org>
Wed, 22 Apr 2026 17:07:30 +0000 (10:07 -0700)
In an attempt to fix REPLACETLSPSK we stopped freeing the secrets on
successful connections. This resulted in memory leaks in the kernel, so
let's revert the commit. A improved fix is being developed to just avoid
clearing the tls_key variable.

This reverts commit 2e6eb6b277f593b98f151ea8eff1beb558bbea3b.

Closes: https://lore.kernel.org/linux-nvme/CAHj4cs-u3MWQR4idywptMfjEYi4YwObWFx4KVib35dZ5HMBDdw@mail.gmail.com
Reviewed-by: Chris Leech <cleech@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/target/fabrics-cmd-auth.c

index b9ab80c7a6941826c40fe33a9c5f95f17f119deb..f1e613e7c63e5198a35775e6d7071a32b310b5da 100644 (file)
@@ -395,10 +395,9 @@ done:
                goto complete;
        }
        /* Final states, clear up variables */
-       if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) {
-               nvmet_auth_sq_free(req->sq);
+       nvmet_auth_sq_free(req->sq);
+       if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE2)
                nvmet_ctrl_fatal_error(ctrl);
-       }
 
 complete:
        nvmet_req_complete(req, status);
@@ -574,7 +573,9 @@ void nvmet_execute_auth_receive(struct nvmet_req *req)
        status = nvmet_copy_to_sgl(req, 0, d, al);
        kfree(d);
 done:
-       if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE1) {
+       if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2)
+               nvmet_auth_sq_free(req->sq);
+       else if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE1) {
                nvmet_auth_sq_free(req->sq);
                nvmet_ctrl_fatal_error(ctrl);
        }