Skip to content

Commit 4bab690

Browse files
ChaitanayaKulkarniChristoph Hellwig
authored andcommitted
nvme-core: put ctrl ref when module ref get fail
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: 52a3974 "nvme-core: get/put ctrl and transport module in nvme_dev_open/release()" Signed-off-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Logan Gunthorpe <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 6d53a9f commit 4bab690

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/nvme/host/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3265,8 +3265,10 @@ static int nvme_dev_open(struct inode *inode, struct file *file)
32653265
}
32663266

32673267
nvme_get_ctrl(ctrl);
3268-
if (!try_module_get(ctrl->ops->module))
3268+
if (!try_module_get(ctrl->ops->module)) {
3269+
nvme_put_ctrl(ctrl);
32693270
return -EINVAL;
3271+
}
32703272

32713273
file->private_data = ctrl;
32723274
return 0;

0 commit comments

Comments
 (0)