mcb: Acquire reference to carrier module in core
Subsystems (2)
PATCH RESEND 1/3 mcb: Acquire reference to device in probe
In reply to a message not in the archivemcb_probe() does not aqcuire a reference to the probed device but drops one when removing the device. As it is actually using the device, it should grab a reference via get_device().
This could lead to a panic found with a rmmod/modprobe stress test
Signed-off-by Johannes Thumshirn <[email protected]>
Reported-by Andreas Werner <[email protected]>
Tested-by Andreas Werner <[email protected]>
Fixes '3764e82e5' drivers: Introduce MEN Chameleon Bus
Cc [email protected] # v3.15+
--- drivers/mcb/mcb-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/mcb/mcb-core.c +1 -0
@@ -66,6 +66,7 @@ static int mcb_probe(struct device *dev)if (!found_id)return -ENODEV ; +get_device (dev);return mdrv->probe (mdev, found_id); }
Signature · 1 line
1.8.5.6
PATCH RESEND 2/3 mcb: Acquire reference to carrier module in core
In reply to a message not in the archiveAcquire a reference to the carrier's kernel module in bus code, so it can't be removed from the kernel while it still has a bus and thus possibly devices attached to it.
Signed-off-by Johannes Thumshirn <[email protected]>
Reported-by Andreas Werner <[email protected]>
Tested-by Andreas Werner <[email protected]>
Fixes '3764e82e5' drivers: Introduce MEN Chameleon Bus
Cc [email protected] # v3.15+
--- drivers/mcb/mcb-core.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/mcb/mcb-core.c +15 -1
@@ -61,22 +61,36 @@ static int mcb_probe(struct device *dev)struct mcb_driver *mdrv =to_mcb_driver (dev->driver);struct mcb_device *mdev =to_mcb_device (dev);const struct mcb_device_id *found_id; +struct module *carrier_mod; +int ret; found_id =mcb_match_id (mdrv->id_table, mdev);if (!found_id)return -ENODEV ; + carrier_mod = mdev->dev.parent->driver->owner; +if (!try_module_get (carrier_mod)) +return -EINVAL ; +get_device (dev); -return mdrv->probe (mdev, found_id); + ret = mdrv->probe (mdev, found_id); +if (ret) +module_put (carrier_mod); + +return ret; }static int mcb_remove (struct device *dev) {struct mcb_driver *mdrv =to_mcb_driver (dev->driver);struct mcb_device *mdev =to_mcb_device (dev); +struct module *carrier_mod; mdrv->remove (mdev); + carrier_mod = mdev->dev.parent->driver->owner; +module_put (carrier_mod); +put_device (&mdev->dev);return 0 ;
Signature · 1 line
1.8.5.6