[zaptel-commits] russell: branch 1.2 r1304 - /branches/1.2/zaptel.c

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Sun Aug 13 21:07:00 MST 2006


Author: russell
Date: Sun Aug 13 23:07:00 2006
New Revision: 1304

URL: http://svn.digium.com/view/zaptel?rev=1304&view=rev
Log:
fix potential deadlock found by kernel's lock checker 
(issue #7620, reported by smurfix, fixed by Corydon)

Modified:
    branches/1.2/zaptel.c

Modified: branches/1.2/zaptel.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/zaptel.c?rev=1304&r1=1303&r2=1304&view=diff
==============================================================================
--- branches/1.2/zaptel.c (original)
+++ branches/1.2/zaptel.c Sun Aug 13 23:07:00 2006
@@ -1091,8 +1091,14 @@
 	/* 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 @@
 	} else {
 		res = -ENODATA;
 	}
-	
+
 	read_unlock(&zone_lock);
 	return res;
 }



More information about the zaptel-commits mailing list