From ee4cf21e67af1575a3df01760c058ba809160775 Mon Sep 17 00:00:00 2001 From: mattf Date: Thu, 16 Nov 2006 23:09:21 +0000 Subject: Fix for 7769. Make sure we lock before modifying flags. git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1603 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- zaptel.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'zaptel.c') diff --git a/zaptel.c b/zaptel.c index df920de..3d0ae85 100644 --- a/zaptel.c +++ b/zaptel.c @@ -2347,8 +2347,10 @@ static int zt_specchan_open(struct inode *inode, struct file *file, int unit, in else if ((chans[unit]->sig & __ZT_SIG_DACS) == __ZT_SIG_DACS) res = -EBUSY; else { + unsigned long flags; /* Assume everything is going to be okay */ res = initialize_channel(chans[unit]); + spin_lock_irqsave(&chans[unit]->lock, flags); if (chans[unit]->flags & ZT_FLAG_PSEUDO) chans[unit]->flags |= ZT_FLAG_AUDIO; if (chans[unit]->span && chans[unit]->span->open) @@ -2360,7 +2362,9 @@ static int zt_specchan_open(struct inode *inode, struct file *file, int unit, in MOD_INC_USE_COUNT; #endif chans[unit]->flags |= ZT_FLAG_OPEN; + spin_unlock_irqrestore(&chans[unit]->lock, flags); } else { + spin_unlock_irqrestore(&chans[unit]->lock, flags); close_channel(chans[unit]); } } @@ -2373,7 +2377,10 @@ static int zt_specchan_release(struct inode *node, struct file *file, int unit) { int res=0; if (chans[unit]) { + unsigned long flags; + spin_lock_irqsave(&chans[unit]->lock, flags); chans[unit]->flags &= ~ZT_FLAG_OPEN; + spin_unlock_irqrestore(&chans[unit]->lock, flags); chans[unit]->file = NULL; close_channel(chans[unit]); if (chans[unit]->span && chans[unit]->span->close) -- cgit v1.2.3