[svn-commits] sruffell: branch linux/2.4 r9682 - /linux/branches/2.4/drivers/dahdi/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jan 20 23:31:30 CST 2011


Author: sruffell
Date: Thu Jan 20 23:31:26 2011
New Revision: 9682

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9682
Log:
dahdi: Prevent unloadable module on failed open.

If chan->span->ops->open() fails then the reference count of the module
implementing the board driver will not be decremented.  The result is a
module that would always be "in use" and unloadable.

This change makes sure to release that reference when open failed.

(closes issue #18422)
Reported by: avarvit

Signed-off-by: Shaun Ruffell <sruffell at digium.com>
Acked-by: Angelos Varvitsiotis <avarvit at admin.grnet.gr>

Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=9510

Modified:
    linux/branches/2.4/drivers/dahdi/dahdi-base.c

Modified: linux/branches/2.4/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/branches/2.4/drivers/dahdi/dahdi-base.c?view=diff&rev=9682&r1=9681&r2=9682
==============================================================================
--- linux/branches/2.4/drivers/dahdi/dahdi-base.c (original)
+++ linux/branches/2.4/drivers/dahdi/dahdi-base.c Thu Jan 20 23:31:26 2011
@@ -2789,6 +2789,7 @@
 			res = -EBUSY;
 		else if (!test_and_set_bit(DAHDI_FLAGBIT_OPEN, &chan->flags)) {
 			unsigned long flags;
+			const struct dahdi_span_ops *ops;
 			res = initialize_channel(chan);
 			if (res) {
 				/* Reallocbufs must have failed */
@@ -2799,10 +2800,14 @@
 			if (chan->flags & DAHDI_FLAG_PSEUDO)
 				chan->flags |= DAHDI_FLAG_AUDIO;
 			if (chan->span) {
-				if (!try_module_get(chan->span->ops->owner))
+				ops = chan->span->ops;
+				if (!try_module_get(ops->owner)) {
 					res = -ENXIO;
-				else if (chan->span->ops->open)
-					res = chan->span->ops->open(chan);
+				} else if (ops->open) {
+					res = ops->open(chan);
+					if (res)
+						module_put(ops->owner);
+				}
 			}
 			if (!res) {
 				chan->file = file;




More information about the svn-commits mailing list