From 3625c5dc5d694ffc3795b5f46c3b0e97686374e9 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Tue, 3 Apr 2012 20:10:03 +0000 Subject: 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 Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10623 git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.6@10628 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/dahdi_dynamic.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'drivers/dahdi/dahdi_dynamic.c') diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c index aec4a7d..832e283 100644 --- a/drivers/dahdi/dahdi_dynamic.c +++ b/drivers/dahdi/dahdi_dynamic.c @@ -823,10 +823,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; @@ -837,19 +840,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"); } -- cgit v1.2.3