diff options
-rwxr-xr-x | zaptel.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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); } } |