summaryrefslogtreecommitdiff
path: root/zaptel.c
diff options
context:
space:
mode:
authorrussell <russell@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-08-14 04:07:49 +0000
committerrussell <russell@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-08-14 04:07:49 +0000
commit02fbc672c6aaad12d8d4fea2ffdaba4b8f0d93e2 (patch)
treeb6c9ac373f8cb093741470b055e35590ce94b4cb /zaptel.c
parent712c8a90aff9de85f3e224cad7b1294744d8b8e5 (diff)
Merged revisions 1304 via svnmerge from
https://origsvn.digium.com/svn/zaptel/branches/1.2 ........ r1304 | russell | 2006-08-14 00:07:00 -0400 (Mon, 14 Aug 2006) | 3 lines fix potential deadlock found by kernel's lock checker (issue #7620, reported by smurfix, fixed by Corydon) ........ git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1305 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'zaptel.c')
-rw-r--r--zaptel.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/zaptel.c b/zaptel.c
index c9e5b76..5a5172d 100644
--- a/zaptel.c
+++ b/zaptel.c
@@ -1135,8 +1135,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;
}
@@ -1147,7 +1153,7 @@ static int set_tone_zone(struct zt_chan *chan, int zone)
} else {
res = -ENODATA;
}
-
+
read_unlock(&zone_lock);
return res;
}