[Asterisk-code-review] chan dahdi/sig pri: Fix crash on ISDN call hangup collision. (asterisk[13])

Joshua Colp asteriskteam at digium.com
Wed May 13 12:24:33 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: chan_dahdi/sig_pri: Fix crash on ISDN call hangup collision.
......................................................................


chan_dahdi/sig_pri: Fix crash on ISDN call hangup collision.

If an ISDN call is hungup by both sides at the same time a crash could
happen.

* Added missing NULL checks for the owner channel after calling
pri_queue_pvt_cause_data() in two places.  Code after those calls need to
check the owner channel pointer for NULL before use because
pri_queue_pvt_cause_data() needs to do deadlock avoidance to lock the
owner and the owner may get hung up.

ASTERISK-21893 #close
Reported by:  Alexandr Gordeev

Change-Id: Ica3e266ebc7a894b41d762326f08653e1904bb9a
---
M channels/sig_pri.c
1 file changed, 6 insertions(+), 4 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, approved; Verified
  Jonathan Rose: Looks good to me, but someone else must approve



diff --git a/channels/sig_pri.c b/channels/sig_pri.c
index a66d16b..2815dac 100644
--- a/channels/sig_pri.c
+++ b/channels/sig_pri.c
@@ -7102,10 +7102,11 @@
 						break;
 					}
 					if (pri->pvts[chanpos]->owner) {
-						int do_hangup = 0;
-
 						snprintf(cause_str, sizeof(cause_str), "PRI PRI_EVENT_HANGUP (%d)", e->hangup.cause);
 						pri_queue_pvt_cause_data(pri, chanpos, cause_str, e->hangup.cause);
+					}
+					if (pri->pvts[chanpos]->owner) {
+						int do_hangup = 0;
 
 						/* Queue a BUSY instead of a hangup if our cause is appropriate */
 						ast_channel_hangupcause_set(pri->pvts[chanpos]->owner, e->hangup.cause);
@@ -7246,10 +7247,11 @@
 					break;
 				}
 				if (pri->pvts[chanpos]->owner) {
-					int do_hangup = 0;
-
 					snprintf(cause_str, sizeof(cause_str), "PRI PRI_EVENT_HANGUP_REQ (%d)", e->hangup.cause);
 					pri_queue_pvt_cause_data(pri, chanpos, cause_str, e->hangup.cause);
+				}
+				if (pri->pvts[chanpos]->owner) {
+					int do_hangup = 0;
 
 					ast_channel_hangupcause_set(pri->pvts[chanpos]->owner, e->hangup.cause);
 					switch (ast_channel_state(pri->pvts[chanpos]->owner)) {

-- 
To view, visit https://gerrit.asterisk.org/446
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ica3e266ebc7a894b41d762326f08653e1904bb9a
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Jonathan Rose <jrose at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list