--- zaptel.c 2007-09-01 09:13:54.976621000 +0300 +++ zaptel.patched.txt 2007-09-01 10:39:50.827289500 +0300 @@ -1707,11 +1707,19 @@ chan->hdlcnetdev = NULL; } #endif - write_lock_irqsave(&chan_lock, flags); + spin_lock_irqsave(&chan->lock, flags); + while (chan->flags & ZT_FLAG_OPEN) { + spin_unlock_irqrestore(&chan->lock, flags); + set_current_state(TASK_INTERRUPTIBLE); + schedule(); + spin_lock_irqsave(&chan->lock, flags); + } + write_lock(&chan_lock); if (chan->flags & ZT_FLAG_REGISTERED) { chans[chan->channo] = NULL; chan->flags &= ~ZT_FLAG_REGISTERED; } + spin_unlock(&chan->lock); #ifdef CONFIG_ZAPATA_PPP if (chan->ppp) { printk("HUH??? PPP still attached??\n");