From 644fbb9766ba8d9e76e710e639bc137e9e2323ac Mon Sep 17 00:00:00 2001 From: markster Date: Wed, 16 Jun 2004 03:52:49 +0000 Subject: Hold the big zap lock when allocating and freeing the pseudo channels git-svn-id: http://svn.digium.com/svn/zaptel/trunk@411 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- zaptel.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'zaptel.c') diff --git a/zaptel.c b/zaptel.c index 1d05fcb..fd15352 100755 --- a/zaptel.c +++ b/zaptel.c @@ -2137,6 +2137,7 @@ static int zt_specchan_release(struct inode *node, struct file *file, int unit) static struct zt_chan *zt_alloc_pseudo(void) { struct zt_chan *pseudo; + unsigned long flags; /* Don't allow /dev/zap/pseudo to open if there are no spans */ if (maxspans < 1) return NULL; @@ -2147,18 +2148,23 @@ static struct zt_chan *zt_alloc_pseudo(void) pseudo->sig = ZT_SIG_CLEAR; pseudo->sigcap = ZT_SIG_CLEAR; pseudo->flags = ZT_FLAG_PSEUDO | ZT_FLAG_AUDIO; + spin_lock_irqsave(&bigzaplock, flags); if (zt_chan_reg(pseudo)) { kfree(pseudo); - return NULL; - } - sprintf(pseudo->name, "Pseudo/%d", pseudo->channo); + pseudo = NULL; + } else + sprintf(pseudo->name, "Pseudo/%d", pseudo->channo); + spin_unlock_irqrestore(&bigzaplock, flags); return pseudo; } static void zt_free_pseudo(struct zt_chan *pseudo) { + unsigned long flags; if (pseudo) { + spin_lock_irqsave(&bigzaplock, flags); zt_chan_unreg(pseudo); + spin_unlock_irqrestore(&bigzaplock, flags); kfree(pseudo); } } -- cgit v1.2.3