public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: Yi Zhang <yi.zhang@redhat.com>, Sagi Grimberg <sagi@grimberg.me>
Cc: linux-block <linux-block@vger.kernel.org>,
	"open list:NVM EXPRESS DRIVER" <linux-nvme@lists.infradead.org>,
	Hannes Reinecke <hare@suse.de>
Subject: Re: [bug report] kmemleak observed during blktests nvme-tcp
Date: Wed, 26 Apr 2023 08:23:44 +0000	[thread overview]
Message-ID: <f74df8a4-03c6-6687-7ada-35aa268f44b9@nvidia.com> (raw)
In-Reply-To: <CAHj4cs99us_r4Ebth5oAJMqHHA9aXZCpq0A3uu1BEdNw2GeRww@mail.gmail.com>


>>>       [<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



  reply	other threads:[~2023-04-26  8:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21  0:37 [bug report] kmemleak observed during blktests nvme-tcp Yi Zhang
2023-04-23 14:15 ` Sagi Grimberg
2023-04-25  9:54   ` Yi Zhang
2023-04-26  8:23     ` Chaitanya Kulkarni [this message]
2023-04-26  8:34       ` Chaitanya Kulkarni
2023-04-27  7:24         ` Yi Zhang
2023-04-27  7:39           ` Yi Zhang
2023-04-27 10:58             ` Chaitanya Kulkarni
2023-04-27 15:57               ` Yi Zhang
2023-05-01  8:23                 ` Chaitanya Kulkarni
2023-05-01  8:44                   ` Sagi Grimberg
2023-05-02  2:35                     ` Chaitanya Kulkarni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f74df8a4-03c6-6687-7ada-35aa268f44b9@nvidia.com \
    --to=chaitanyak@nvidia.com \
    --cc=hare@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=yi.zhang@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox