diff options
Diffstat (limited to 'zaptel.c')
-rw-r--r-- | zaptel.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -1091,8 +1091,14 @@ static int set_tone_zone(struct zt_chan *chan, int zone) /* Assumes channel is already locked */ if ((zone >= ZT_TONE_ZONE_MAX) || (zone < -1)) return -EINVAL; - - read_lock(&zone_lock); + + /* Since this routine is called both from IRQ as well as from userspace, + * it is possible that we could be called during an IRQ while userspace + * has locked this. However unlikely, this could possibly cause a + * deadlock. */ + if (! read_trylock(&zone_lock)) + return -EWOULDBLOCK; + if (zone == -1) { zone = default_zone; } @@ -1103,7 +1109,7 @@ static int set_tone_zone(struct zt_chan *chan, int zone) } else { res = -ENODATA; } - + read_unlock(&zone_lock); return res; } |