[svn-commits] sruffell: linux/trunk r9510 - /linux/trunk/drivers/dahdi/dahdi-base.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Dec 7 08:20:44 CST 2010
Author: sruffell
Date: Tue Dec 7 08:20:38 2010
New Revision: 9510
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9510
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>
Modified:
linux/trunk/drivers/dahdi/dahdi-base.c
Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=9510&r1=9509&r2=9510
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Tue Dec 7 08:20:38 2010
@@ -2756,6 +2756,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 */
@@ -2763,13 +2764,17 @@
return res;
}
spin_lock_irqsave(&chan->lock, flags);
+ ops = chan->span->ops;
if (is_pseudo_chan(chan))
chan->flags |= DAHDI_FLAG_AUDIO;
if (chan->span) {
- if (!try_module_get(chan->span->ops->owner))
+ 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