Skip to content

Commit 85094c0

Browse files
hiss2018torvalds
authored andcommitted
rapidio: fix the missed put_device() for rio_mport_add_riodev
rio_mport_add_riodev() misses to call put_device() when the device already exists. Add the missed function call to fix it. Fixes: e8de370 ("rapidio: add mport char device driver") Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: Alexandre Bounine <alex.bou9@gmail.com> Cc: Gustavo A. R. Silva <gustavoars@kernel.org> Cc: John Hubbard <jhubbard@nvidia.com> Cc: Kees Cook <keescook@chromium.org> Cc: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com> Link: https://lkml.kernel.org/r/20200922072525.42330-1-jingxiangfeng@huawei.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent fa63f08 commit 85094c0

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/rapidio/devices/rio_mport_cdev.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,7 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,
16801680
struct rio_dev *rdev;
16811681
struct rio_switch *rswitch = NULL;
16821682
struct rio_mport *mport;
1683+
struct device *dev;
16831684
size_t size;
16841685
u32 rval;
16851686
u32 swpinfo = 0;
@@ -1694,8 +1695,10 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,
16941695
rmcd_debug(RDEV, "name:%s ct:0x%x did:0x%x hc:0x%x", dev_info.name,
16951696
dev_info.comptag, dev_info.destid, dev_info.hopcount);
16961697

1697-
if (bus_find_device_by_name(&rio_bus_type, NULL, dev_info.name)) {
1698+
dev = bus_find_device_by_name(&rio_bus_type, NULL, dev_info.name);
1699+
if (dev) {
16981700
rmcd_debug(RDEV, "device %s already exists", dev_info.name);
1701+
put_device(dev);
16991702
return -EEXIST;
17001703
}
17011704

0 commit comments

Comments
 (0)