From: zhangqilong <zhangqilong3@huawei.com>
To: Sagi Grimberg <sagi@grimberg.me>, "hare@suse.de" <hare@suse.de>,
"kbusch@kernel.org" <kbusch@kernel.org>,
"axboe@fb.com" <axboe@fb.com>, "hch@lst.de" <hch@lst.de>
Cc: "linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>
Subject: 答复: [PATCH] nvme: fix memleak in nvme_ctrl_dhchap_secret_store()
Date: Mon, 21 Nov 2022 11:33:22 +0000 [thread overview]
Message-ID: <dacd7300dfe54845b6a5ef2ee8f940d7@huawei.com> (raw)
In-Reply-To: <b86df48d-2fd2-fe90-a1c2-721cb51d826e@grimberg.me>
>
> > If dhchap_secret is not consistent with options or
> > nvme_auth_generate_key() fails, we should free the memory of
> > dhchap_secret to avoid memleak.
> >
> > Fixes: f50fff73d620 ("nvme: implement In-Band authentication")
> > Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
>
> Please have a look at nvme-6.2, if there is still a leak, please send a patch
> against it.
>
Hi
I have checked it, there is still a leak at nvme-6.2.
Thanks.
> Thanks.
>
> > ---
> > drivers/nvme/host/core.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index
> > da55ce45ac70..e06d1b3961fe 100644
> > --- a/drivers/nvme/host/core.c
> > +++ b/drivers/nvme/host/core.c
> > @@ -3748,13 +3748,16 @@ static ssize_t
> nvme_ctrl_dhchap_secret_store(struct device *dev,
> > int ret;
> >
> > ret = nvme_auth_generate_key(dhchap_secret, &ctrl-
> >host_key);
> > - if (ret)
> > + if (ret) {
> > + kfree(dhchap_secret);
> > return ret;
> > + }
> > kfree(opts->dhchap_secret);
> > opts->dhchap_secret = dhchap_secret;
> > /* Key has changed; re-authentication with new key */
> > nvme_auth_reset(ctrl);
> > - }
> > + } else
> > + kfree(dhchap_secret);
> > /* Start re-authentication */
> > dev_info(ctrl->device, "re-authenticating controller\n");
> > queue_work(nvme_wq, &ctrl->dhchap_auth_work);
next prev parent reply other threads:[~2022-11-21 11:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 6:21 [PATCH] nvme: fix memleak in nvme_ctrl_dhchap_secret_store() Zhang Qilong
2022-11-21 9:51 ` Sagi Grimberg
2022-11-21 11:33 ` zhangqilong [this message]
2022-11-21 11:39 ` 答复: " Sagi Grimberg
2022-11-21 11:54 ` 答复: " zhangqilong
2022-11-21 14:23 ` Sagi Grimberg
2022-11-21 15:09 ` 答复: " zhangqilong
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=dacd7300dfe54845b6a5ef2ee8f940d7@huawei.com \
--to=zhangqilong3@huawei.com \
--cc=axboe@fb.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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