--- dahdi-linux-2.4.0.orig/drivers/dahdi/dahdi-base.c 2010-08-20 03:12:43.000000000 +0200 +++ dahdi-linux-2.4.0/drivers/dahdi/dahdi-base.c 2011-01-24 10:54:54.000000000 +0200 @@ -47,8 +47,9 @@ #include #include #include +#include -#ifdef HAVE_UNLOCKED_IOCTL +#if defined(HAVE_UNLOCKED_IOCTL) && defined(CONFIG_BKL) #include #endif @@ -383,6 +384,7 @@ static spinlock_t zaptimerlock = SPIN_LOCK_UNLOCKED; static spinlock_t bigzaplock = SPIN_LOCK_UNLOCKED; #endif +DEFINE_MUTEX(global_dialparamslock); struct dahdi_zone { atomic_t refcount; @@ -3066,6 +3068,7 @@ atomic_set(&z->refcount, 0); + mutex_lock(&global_dialparamslock); for (x = 0; x < work->th.count; x++) { enum { REGULAR_TONE, @@ -3195,6 +3198,7 @@ break; } } + mutex_unlock(&global_dialparamslock); for (x = 0; x < work->th.count; x++) { if (work->samples[x]) @@ -4476,6 +4480,8 @@ if (copy_from_user(&tdp, user_data, sizeof(tdp))) return -EFAULT; + mutex_lock(&global_dialparamslock); + if ((tdp.dtmf_tonelen >= 10) && (tdp.dtmf_tonelen <= 4000)) { global_dialparams.dtmf_tonelen = tdp.dtmf_tonelen; } @@ -4517,13 +4523,18 @@ mfr1_silence.tonesamples = global_dialparams.mfv1_tonelen * DAHDI_CHUNKSIZE; mfr2_silence.tonesamples = global_dialparams.mfr2_tonelen * DAHDI_CHUNKSIZE; + mutex_unlock(&global_dialparamslock); + break; } case DAHDI_GET_DIALPARAMS: { struct dahdi_dialparams tdp; + mutex_lock(&global_dialparamslock); tdp = global_dialparams; + mutex_unlock(&global_dialparamslock); + if (copy_to_user(user_data, &tdp, sizeof(tdp))) return -EFAULT; break; @@ -5838,19 +5849,14 @@ return 0; } -#ifdef HAVE_UNLOCKED_IOCTL -static long dahdi_ioctl(struct file *file, unsigned int cmd, unsigned long data) -#else -static int dahdi_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long data) -#endif +static long dahdi_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long data) { int unit = UNIT(file); struct dahdi_chan *chan; struct dahdi_timer *timer; int ret; -#ifdef HAVE_UNLOCKED_IOCTL +#if defined(HAVE_UNLOCKED_IOCTL) && defined(CONFIG_BKL) lock_kernel(); #endif @@ -5896,12 +5902,20 @@ ret = dahdi_chan_ioctl(file, cmd, data, unit); unlock_exit: -#ifdef HAVE_UNLOCKED_IOCTL +#if defined(HAVE_UNLOCKED_IOCTL) && defined(CONFIG_BKL) unlock_kernel(); #endif return ret; } +#ifndef HAVE_UNLOCKED_IOCTL +static int dahdi_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long data) +{ + return dahdi_unlocked_ioctl(file, cmd, data); +} +#endif + #ifdef HAVE_COMPAT_IOCTL static long dahdi_ioctl_compat(struct file *file, unsigned int cmd, unsigned long data) @@ -5909,7 +5923,7 @@ if (cmd == DAHDI_SFCONFIG) return -ENOTTY; /* Not supported yet */ - return dahdi_ioctl(file, cmd, data); + return dahdi_unlocked_ioctl(file, cmd, data); } #endif @@ -8603,7 +8617,7 @@ .open = dahdi_open, .release = dahdi_release, #ifdef HAVE_UNLOCKED_IOCTL - .unlocked_ioctl = dahdi_ioctl, + .unlocked_ioctl = dahdi_unlocked_ioctl, #ifdef HAVE_COMPAT_IOCTL .compat_ioctl = dahdi_ioctl_compat, #endif