diff options
author | Richard Mudgett <rmudgett@digium.com> | 2016-08-22 15:01:37 -0500 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2016-08-25 17:11:50 -0500 |
commit | 5744f434f0eaba9633e7574d9cd0f8193dfd67e1 (patch) | |
tree | edf5d6ce291ea2840395e467c30bb4deab49970d /res/res_pjsip_t38.c | |
parent | d2e03c252d128d43fdbfe5906e238e8e0f90c0ab (diff) |
ast_framehook_attach() must be called with the channel locked.
The framehook container could become corrupted if the channel lock is not
held before calling.
Change-Id: I1a6b957a1f7b899eb29a186915f8cccab886a438
Diffstat (limited to 'res/res_pjsip_t38.c')
-rw-r--r-- | res/res_pjsip_t38.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c index 76720acee..150336a08 100644 --- a/res/res_pjsip_t38.c +++ b/res/res_pjsip_t38.c @@ -501,25 +501,27 @@ static void t38_attach_framehook(struct ast_sip_session *session) return; } - /* Skip attaching the framehook if the T.38 datastore already exists for the channel */ ast_channel_lock(session->channel); - if ((datastore = ast_channel_datastore_find(session->channel, &t38_framehook_datastore, NULL))) { + + /* Skip attaching the framehook if the T.38 datastore already exists for the channel */ + datastore = ast_channel_datastore_find(session->channel, &t38_framehook_datastore, + NULL); + if (datastore) { ast_channel_unlock(session->channel); return; } - ast_channel_unlock(session->channel); framehook_id = ast_framehook_attach(session->channel, &hook); if (framehook_id < 0) { - ast_log(LOG_WARNING, "Could not attach T.38 Frame hook to channel, T.38 will be unavailable on '%s'\n", + ast_log(LOG_WARNING, "Could not attach T.38 Frame hook, T.38 will be unavailable on '%s'\n", ast_channel_name(session->channel)); + ast_channel_unlock(session->channel); return; } - ast_channel_lock(session->channel); datastore = ast_datastore_alloc(&t38_framehook_datastore, NULL); if (!datastore) { - ast_log(LOG_ERROR, "Could not attach T.38 Frame hook to channel, T.38 will be unavailable on '%s'\n", + ast_log(LOG_ERROR, "Could not alloc T.38 Frame hook datastore, T.38 will be unavailable on '%s'\n", ast_channel_name(session->channel)); ast_framehook_detach(session->channel, framehook_id); ast_channel_unlock(session->channel); |