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;