Skip to content
Snippets Groups Projects
Commit b5962425 authored by Cai Xinchen's avatar Cai Xinchen Committed by Greg Kroah-Hartman
Browse files

rapidio: devices: fix missing put_device in mport_cdev_open

[ Upstream commit d5b6e6eb ]

When kfifo_alloc fails, the refcount of chdev->dev is left incremental.
We should use put_device(&chdev->dev) to decrease the ref count of
chdev->dev to avoid refcount leak.

Link: https://lkml.kernel.org/r/20221203085721.13146-1-caixinchen1@huawei.com


Fixes: e8de3701 ("rapidio: add mport char device driver")
Signed-off-by: default avatarCai Xinchen <caixinchen1@huawei.com>
Cc: Alexandre Bounine <alex.bou9@gmail.com>
Cc: Dan Carpenter <error27@gmail.com>
Cc: Jakob Koschel <jakobkoschel@gmail.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Wang Weiyang <wangweiyang2@huawei.com>
Cc: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 88579c15
No related branches found
No related tags found
No related merge requests found
...@@ -1912,6 +1912,7 @@ static int mport_cdev_open(struct inode *inode, struct file *filp) ...@@ -1912,6 +1912,7 @@ static int mport_cdev_open(struct inode *inode, struct file *filp)
sizeof(struct rio_event) * MPORT_EVENT_DEPTH, sizeof(struct rio_event) * MPORT_EVENT_DEPTH,
GFP_KERNEL); GFP_KERNEL);
if (ret < 0) { if (ret < 0) {
put_device(&chdev->dev);
dev_err(&chdev->dev, DRV_NAME ": kfifo_alloc failed\n"); dev_err(&chdev->dev, DRV_NAME ": kfifo_alloc failed\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err_fifo; goto err_fifo;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment