[bug report] kmemleak observed during blktests nvme-tcp

Chaitanya Kulkarni chaitanyak at nvidia.com
Wed Apr 26 01:23:44 PDT 2023


>>>       [<ffffffff86f646ab>] __kmalloc+0x4b/0x190
>>>       [<ffffffffc09fb710>] nvme_ctrl_dhchap_secret_store+0x110/0x350 [nvme_core]
>>>       [<ffffffff873cc848>] kernfs_fop_write_iter+0x358/0x530
>>>       [<ffffffff871b47d2>] vfs_write+0x802/0xc60
>>>       [<ffffffff871b5479>] ksys_write+0xf9/0x1d0
>>>       [<ffffffff88ba8f9c>] do_syscall_64+0x5c/0x90
>>>       [<ffffffff88c000aa>] entry_SYSCALL_64_after_hwframe+0x72/0xdc

can you check if following fixes your problem for dhchap ?


linux-block (for-next) # git diff
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 1bfd52eae2ee..0e22d048de3c 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3825,8 +3825,10 @@ static ssize_t 
nvme_ctrl_dhchap_secret_store(struct device *dev,
                 int ret;

                 ret = nvme_auth_generate_key(dhchap_secret, &key);
-               if (ret)
+               if (ret) {
+                       kfree(dhchap_secret);
                         return ret;
+               }
                 kfree(opts->dhchap_secret);
                 opts->dhchap_secret = dhchap_secret;
                 host_key = ctrl->host_key;
@@ -3879,8 +3881,10 @@ static ssize_t 
nvme_ctrl_dhchap_ctrl_secret_store(struct device *dev,
                 int ret;

                 ret = nvme_auth_generate_key(dhchap_secret, &key);
-               if (ret)
+               if (ret) {
+                       kfree(dhchap_secret);
                         return ret;
+               }
                 kfree(opts->dhchap_ctrl_secret);
                 opts->dhchap_ctrl_secret = dhchap_secret;
                 ctrl_key = ctrl->ctrl_key;

-ck




More information about the Linux-nvme mailing list