summaryrefslogtreecommitdiff
path: root/drivers/dahdi/dahdi_dynamic.c
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2012-04-03 19:44:27 +0000
committerShaun Ruffell <sruffell@digium.com>2012-04-03 19:44:27 +0000
commit5a9e9d4f8b7c38a9fff9e4c2c4499dcdee82d2e6 (patch)
tree8614408a2988c4c3c14d3d5bdfc3cbbda44da749 /drivers/dahdi/dahdi_dynamic.c
parent6dbace7374c2f27f50762a5445b28960a135c718 (diff)
dahdi_dynamic: Do not call into dahdi_dynamic without holding reference.
Instead of registering a function pointer, register a dahdi_dynamic_ops structure that contains the owner as well as the ioctl callback. This way dahdi.ko can bump up the reference count on dahdi_dynamic.ko before calling the ioctl callback. Also, use the registration mutex to guard against the module being unloaded between the time the structure pointer was checked, and the module reference is taken. Signed-off-by: Shaun Ruffell <sruffell@digium.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10623 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/dahdi_dynamic.c')
-rw-r--r--drivers/dahdi/dahdi_dynamic.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c
index 79c8bba..602ebe9 100644
--- a/drivers/dahdi/dahdi_dynamic.c
+++ b/drivers/dahdi/dahdi_dynamic.c
@@ -818,10 +818,13 @@ static void check_for_red_alarm(unsigned long ignored)
mod_timer(&alarmcheck, jiffies + 1 * HZ);
}
+static const struct dahdi_dynamic_ops dahdi_dynamic_ops = {
+ .owner = THIS_MODULE,
+ .ioctl = dahdi_dynamic_ioctl,
+};
+
static int dahdi_dynamic_init(void)
{
- dahdi_set_dynamic_ioctl(dahdi_dynamic_ioctl);
-
/* Start process to check for RED ALARM */
init_timer(&alarmcheck);
alarmcheck.expires = 0;
@@ -832,19 +835,22 @@ static int dahdi_dynamic_init(void)
#ifdef ENABLE_TASKLETS
tasklet_init(&dahdi_dynamic_tlet, dahdi_dynamic_tasklet, 0);
#endif
+ dahdi_set_dynamic_ops(&dahdi_dynamic_ops);
+
printk(KERN_INFO "DAHDI Dynamic Span support LOADED\n");
return 0;
}
static void dahdi_dynamic_cleanup(void)
{
+ dahdi_set_dynamic_ops(NULL);
+
#ifdef ENABLE_TASKLETS
if (taskletpending) {
tasklet_disable(&dahdi_dynamic_tlet);
tasklet_kill(&dahdi_dynamic_tlet);
}
#endif
- dahdi_set_dynamic_ioctl(NULL);
del_timer(&alarmcheck);
printk(KERN_INFO "DAHDI Dynamic Span support unloaded\n");
}