aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mcb
diff options
context:
space:
mode:
authorJohannes Thumshirn <jthumshirn@suse.de>2016-05-10 06:39:45 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-06-13 21:49:30 -0400
commit4d2ec8575357d4afc965564e2e910a72fe608d39 (patch)
treee35ecd261822a8dc107b5870031c862146c92ea7 /drivers/mcb
parent7bc364097a89a0a9a5e5e4989d6b3e6fb2027a9e (diff)
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.c16
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)
61 struct mcb_driver *mdrv = to_mcb_driver(dev->driver); 61 struct mcb_driver *mdrv = to_mcb_driver(dev->driver);
62 struct mcb_device *mdev = to_mcb_device(dev); 62 struct mcb_device *mdev = to_mcb_device(dev);
63 const struct mcb_device_id *found_id; 63 const struct mcb_device_id *found_id;
64 struct module *carrier_mod;
65 int ret;
64 66
65 found_id = mcb_match_id(mdrv->id_table, mdev); 67 found_id = mcb_match_id(mdrv->id_table, mdev);
66 if (!found_id) 68 if (!found_id)
67 return -ENODEV; 69 return -ENODEV;
68 70
71 carrier_mod = mdev->dev.parent->driver->owner;
72 if (!try_module_get(carrier_mod))
73 return -EINVAL;
74
69 get_device(dev); 75 get_device(dev);
70 return mdrv->probe(mdev, found_id); 76 ret = mdrv->probe(mdev, found_id);
77 if (ret)
78 module_put(carrier_mod);
79
80 return ret;
71} 81}
72 82
73static int mcb_remove(struct device *dev) 83static int mcb_remove(struct device *dev)
74{ 84{
75 struct mcb_driver *mdrv = to_mcb_driver(dev->driver); 85 struct mcb_driver *mdrv = to_mcb_driver(dev->driver);
76 struct mcb_device *mdev = to_mcb_device(dev); 86 struct mcb_device *mdev = to_mcb_device(dev);
87 struct module *carrier_mod;
77 88
78 mdrv->remove(mdev); 89 mdrv->remove(mdev);
79 90
91 carrier_mod = mdev->dev.parent->driver->owner;
92 module_put(carrier_mod);
93
80 put_device(&mdev->dev); 94 put_device(&mdev->dev);
81 95
82 return 0; 96 return 0;