diff options
author | Johannes Thumshirn <jthumshirn@suse.de> | 2016-05-10 12:39:45 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-06-13 18:49:30 -0700 |
commit | 4d2ec8575357d4afc965564e2e910a72fe608d39 (patch) | |
tree | e35ecd261822a8dc107b5870031c862146c92ea7 /drivers/mcb | |
parent | 7bc364097a89a0a9a5e5e4989d6b3e6fb2027a9e (diff) | |
download | linux-4d2ec8575357d4afc965564e2e910a72fe608d39.tar.gz linux-4d2ec8575357d4afc965564e2e910a72fe608d39.tar.bz2 linux-4d2ec8575357d4afc965564e2e910a72fe608d39.zip |
mcb: Acquire reference to carrier module in core
Acquire 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 <jthumshirn@suse.de>
Reported-by: Andreas Werner <andreas.werner@men.de>
Tested-by: Andreas Werner <andreas.werner@men.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/mcb')
-rw-r--r-- | drivers/mcb/mcb-core.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c index f5923c253f7e..6f2c8522e14a 100644 --- a/drivers/mcb/mcb-core.c +++ b/drivers/mcb/mcb-core.c @@ -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; |