Skip to content

Commit

Permalink
rapidio: devices: fix missing put_device in mport_cdev_open
Browse files Browse the repository at this point in the history
[ Upstream commit d5b6e6eba3af11cb2a2791fa36a2524990fcde1a ]

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/[email protected]
Fixes: e8de370 ("rapidio: add mport char device driver")
Signed-off-by: Cai Xinchen <[email protected]>
Cc: Alexandre Bounine <[email protected]>
Cc: Dan Carpenter <[email protected]>
Cc: Jakob Koschel <[email protected]>
Cc: John Hubbard <[email protected]>
Cc: Matt Porter <[email protected]>
Cc: Wang Weiyang <[email protected]>
Cc: Yang Yingliang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Caixinchen1 authored and gregkh committed Jan 7, 2023
1 parent 8399318 commit 6e4540e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/rapidio/devices/rio_mport_cdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,7 @@ static int mport_cdev_open(struct inode *inode, struct file *filp)
sizeof(struct rio_event) * MPORT_EVENT_DEPTH,
GFP_KERNEL);
if (ret < 0) {
put_device(&chdev->dev);
dev_err(&chdev->dev, DRV_NAME ": kfifo_alloc failed\n");
ret = -ENOMEM;
goto err_fifo;
Expand Down

0 comments on commit 6e4540e

Please sign in to comment.