aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJing Xiangfeng <[email protected]>2020-10-15 20:13:18 -0700
committerLinus Torvalds <[email protected]>2020-10-16 11:11:22 -0700
commit85094c05eeb47d195a74a25366a2db066f1c9d47 (patch)
tree4bc4c1683fd8e42367f1f2ffcb7706ebbcd18d94
parentfa63f083b3492b5ed5332b8d7c90b03b5ef24a1d (diff)
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: e8de370188d0 ("rapidio: add mport char device driver") Signed-off-by: Jing Xiangfeng <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Cc: Matt Porter <[email protected]> Cc: Alexandre Bounine <[email protected]> Cc: Gustavo A. R. Silva <[email protected]> Cc: John Hubbard <[email protected]> Cc: Kees Cook <[email protected]> Cc: Madhuparna Bhowmik <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--drivers/rapidio/devices/rio_mport_cdev.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 163b6c72501d..94331d999d27 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -1680,6 +1680,7 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,
struct rio_dev *rdev;
struct rio_switch *rswitch = NULL;
struct rio_mport *mport;
+ struct device *dev;
size_t size;
u32 rval;
u32 swpinfo = 0;
@@ -1694,8 +1695,10 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,
rmcd_debug(RDEV, "name:%s ct:0x%x did:0x%x hc:0x%x", dev_info.name,
dev_info.comptag, dev_info.destid, dev_info.hopcount);
- if (bus_find_device_by_name(&rio_bus_type, NULL, dev_info.name)) {
+ dev = bus_find_device_by_name(&rio_bus_type, NULL, dev_info.name);
+ if (dev) {
rmcd_debug(RDEV, "device %s already exists", dev_info.name);
+ put_device(dev);
return -EEXIST;
}