[asterisk-commits] rmudgett: branch 11 r378094 - in /branches/11: ./ main/loader.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Dec 17 17:09:48 CST 2012
Author: rmudgett
Date: Mon Dec 17 17:09:45 2012
New Revision: 378094
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378094
Log:
Fix potential double free when unloading a module.
........
Merged revisions 378092 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 378093 from http://svn.asterisk.org/svn/asterisk/branches/10
Modified:
branches/11/ (props changed)
branches/11/main/loader.c
Propchange: branches/11/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.
Modified: branches/11/main/loader.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/loader.c?view=diff&rev=378094&r1=378093&r2=378094
==============================================================================
--- branches/11/main/loader.c (original)
+++ branches/11/main/loader.c Mon Dec 17 17:09:45 2012
@@ -237,9 +237,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);
@@ -559,15 +568,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