[asterisk-commits] rmudgett: branch 10 r378093 - in /branches/10: ./ main/loader.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Dec 17 17:08:43 CST 2012
Author: rmudgett
Date: Mon Dec 17 17:08:40 2012
New Revision: 378093
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378093
Log:
Fix potential double free when unloading a module.
........
Merged revisions 378092 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Modified:
branches/10/ (props changed)
branches/10/main/loader.c
Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: branches/10/main/loader.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/main/loader.c?view=diff&rev=378093&r1=378092&r2=378093
==============================================================================
--- branches/10/main/loader.c (original)
+++ branches/10/main/loader.c Mon Dec 17 17:08:40 2012
@@ -233,9 +233,18 @@
if (!u) {
return;
}
+
AST_LIST_LOCK(&mod->users);
- AST_LIST_REMOVE(&mod->users, u, entry);
+ u = AST_LIST_REMOVE(&mod->users, u, entry);
AST_LIST_UNLOCK(&mod->users);
+ if (!u) {
+ /*
+ * Was not in the list. Either a bad pointer or
+ * __ast_module_user_hangup_all() has been called.
+ */
+ return;
+ }
+
ast_atomic_fetchadd_int(&mod->usecount, -1);
ast_free(u);
@@ -554,15 +563,26 @@
}
if (!error) {
+ /* Request any channels attached to the module to hangup. */
__ast_module_user_hangup_all(mod);
+
res = mod->info->unload();
-
if (res) {
ast_log(LOG_WARNING, "Firm unload failed for %s\n", resource_name);
- if (force <= AST_FORCE_FIRM)
+ if (force <= AST_FORCE_FIRM) {
error = 1;
- else
+ } else {
ast_log(LOG_WARNING, "** Dangerous **: Unloading resource anyway, at user request\n");
+ }
+ }
+
+ if (!error) {
+ /*
+ * Request hangup on any channels that managed to get attached
+ * while we called the module unload function.
+ */
+ __ast_module_user_hangup_all(mod);
+ sched_yield();
}
}
More information about the asterisk-commits
mailing list