| Date | Mon, 5 Oct 2020 22:58:03 +0200 | From | Pavel Machek <> | Subject | Re: [PATCH 4.19 17/38] nvme-core: get/put ctrl and transport module in nvme_dev_open/release() |
| |
Hi!
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > index 33dad9774da01..9ea3d8e611005 100644 > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -2605,10 +2605,24 @@ static int nvme_dev_open(struct inode *inode, struct file *file) > return -EWOULDBLOCK; > } > > + nvme_get_ctrl(ctrl); > + if (!try_module_get(ctrl->ops->module)) > + return -EINVAL;
This needs to do nvme_put_ctrl(ctrl); before returning, right?
Otherwise we leak the reference.
Plus, I'm not sure EINVAL is right error return. EBUSY?
Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 9ea3d8e61100..01c36f3dd87f 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2606,8 +2606,10 @@ static int nvme_dev_open(struct inode *inode, struct file *file) } nvme_get_ctrl(ctrl); - if (!try_module_get(ctrl->ops->module)) - return -EINVAL; + if (!try_module_get(ctrl->ops->module)) { + nvme_put_ctrl(ctrl); + return -EBUSY; + } file->private_data = ctrl; return 0;
-- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html [unhandled content-type:application/pgp-signature] |