From: Logan Gunthorpe <logang@deltatee.com>
To: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
linux-nvme@lists.infradead.org
Cc: kbusch@kernel.org, hch@lst.de, sagi@grimberg.me
Subject: Re: [PATCH] nvme-core: put ctrl ref when module ref get fail
Date: Tue, 6 Oct 2020 18:20:00 -0600 [thread overview]
Message-ID: <e2c46d78-972b-dd7c-6662-edbf91a095fa@deltatee.com> (raw)
In-Reply-To: <20201006233647.57760-1-chaitanya.kulkarni@wdc.com>
On 2020-10-06 5:36 p.m., Chaitanya Kulkarni wrote:
> When try_module_get() fails in the nvme_dev_open() it returns without
> releasing the ctrl reference which was taken earlier.
>
> Put the ctrl reference which is taken before calling the
> try_module_get() in the error return code path.
>
> Fixes: 52a3974feb1a "nvme-core: get/put ctrl and transport module in nvme_dev_open/release()"
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
I guess I missed this too in my review of that patch. Nice catch.
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
> ---
> drivers/nvme/host/core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index c20ce8eabe82..56e2a22e8a02 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3158,8 +3158,10 @@ static int nvme_dev_open(struct inode *inode, struct file *file)
> }
>
> nvme_get_ctrl(ctrl);
> - if (!try_module_get(ctrl->ops->module))
> + if (!try_module_get(ctrl->ops->module)) {
> + nvme_put_ctrl(ctrl);
> return -EINVAL;
> + }
>
> file->private_data = ctrl;
> return 0;
>
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2020-10-07 0:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-06 23:36 [PATCH] nvme-core: put ctrl ref when module ref get fail Chaitanya Kulkarni
2020-10-07 0:20 ` Logan Gunthorpe [this message]
2020-10-07 5:55 ` Christoph Hellwig
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=e2c46d78-972b-dd7c-6662-edbf91a095fa@deltatee.com \
--to=logang@deltatee.com \
--cc=chaitanya.kulkarni@wdc.com \
--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