diff options
author | George Joseph <george.joseph@fairview5.com> | 2015-04-09 23:12:13 +0000 |
---|---|---|
committer | George Joseph <george.joseph@fairview5.com> | 2015-04-09 23:12:13 +0000 |
commit | ed6b6e3c03d9ab54bb3fcb2fe3c912837dd3a007 (patch) | |
tree | 3b1ba5bb70c878eb2d2c038a0693222f7ca721cf /res/res_phoneprov.c | |
parent | 9a63ada03af4a9c65819d21de727817bed93690a (diff) |
res_pjsip_phoneprov_provider: Fix reference leak on unload
res_pjsip_phoneprov_provider was leaking references to phoneprov objects due to
a missing OBJ_NODATA in an ao2_callback in load_users(). Rather than adding the
OBJ_NODATA, I changed load_users to use a more straightforward ao2_iterator.
This plugged the leak but exposed an unload order issue between
res_pjsip_phoneprov_provider, res_phoneprov and res_pjsip.
res_pjsip_phoneprov_provider unloads first, then res_phoneprov, then res_pjsip.
Since res_pjsip_phoneprov_provider uses res_pjsip's sorcery instance, when it
unloads, it's objects are still in the sorcery instance. When res_pjsip
unloads, it destroys all its objects including res_pjsip_phoneprov_provider's.
The phoneprov destructor then attempts to unregister the extension from
res_phoneprov but because res_phoneprov is already cleaned up, its users
container is gone and we get a FRACK.
Simple solution, check for the NULL users container before attempting to remove
the entry. Duh.
Ran tests/res_phoneprov/res_phoneprov_provider. No leaks in
res_pjsip_phoneprov_provider and no FRACKs.
Reported-by: Corey Farrell
Tested-by: George Joseph
Review: https://reviewboard.asterisk.org/r/4608/
ASTERISK-24935 #close
........
Merged revisions 434545 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434547 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_phoneprov.c')
-rw-r--r-- | res/res_phoneprov.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/res/res_phoneprov.c b/res/res_phoneprov.c index ccaa6d246..51c03dbf9 100644 --- a/res/res_phoneprov.c +++ b/res/res_phoneprov.c @@ -1581,12 +1581,20 @@ static int extension_delete_cb(void *obj, void *arg, void *data, int flags) void ast_phoneprov_delete_extension(char *provider_name, char *macaddress) { + if (!users) { + return; + } + ao2_callback_data(users, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE | OBJ_SEARCH_KEY, extension_delete_cb, macaddress, provider_name); } void ast_phoneprov_delete_extensions(char *provider_name) { + if (!users) { + return; + } + ao2_callback(users, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, extensions_delete_cb, provider_name); } |