Fix a refcount bug when freeing an association.

While there: Change code to be consistent.
Discussed with rrs@.
MFC after: 3 days
This commit is contained in:
Michael Tuexen 2012-07-17 13:03:47 +00:00
parent e0d20e6615
commit d07b2ac6c6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=238550
2 changed files with 7 additions and 9 deletions

View File

@ -4875,6 +4875,7 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
/* now clean up any chunks here */
TAILQ_FOREACH_SAFE(sp, &outs->outqueue, next, nsp) {
TAILQ_REMOVE(&outs->outqueue, sp, next);
sctp_free_spbufspace(stcb, asoc, sp);
if (sp->data) {
if (so) {
/* Still an open socket - report */
@ -4885,19 +4886,14 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
sctp_m_freem(sp->data);
sp->data = NULL;
sp->tail_mbuf = NULL;
sp->length = 0;
}
}
if (sp->net) {
sctp_free_remote_addr(sp->net);
sp->net = NULL;
}
sctp_free_spbufspace(stcb, asoc, sp);
if (sp->holds_key_ref)
sctp_auth_key_release(stcb, sp->auth_keyid, SCTP_SO_LOCKED);
/* Free the zone stuff */
SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_strmoq), sp);
SCTP_DECR_STRMOQ_COUNT();
/* sa_ignore FREED_MEMORY */
sctp_free_a_strmoq(stcb, sp, SCTP_SO_LOCKED);
}
}
/* sa_ignore FREED_MEMORY */

View File

@ -3774,6 +3774,8 @@ sctp_report_all_outbound(struct sctp_tcb *stcb, uint16_t error, int holds_lock,
if (sp->data) {
sctp_m_freem(sp->data);
sp->data = NULL;
sp->tail_mbuf = NULL;
sp->length = 0;
}
}
if (sp->net) {
@ -4833,7 +4835,7 @@ sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1,
/*
* Pull any data to free up the SB
* and allow sender to "add more"
* whilc we will throw away :-)
* while we will throw away :-)
*/
sctp_free_spbufspace(stcb, &stcb->asoc,
sp);
@ -4841,9 +4843,9 @@ sctp_release_pr_sctp_chunk(struct sctp_tcb *stcb, struct sctp_tmit_chunk *tp1,
do_wakeup_routine = 1;
sp->some_taken = 1;
sctp_m_freem(sp->data);
sp->length = 0;
sp->data = NULL;
sp->tail_mbuf = NULL;
sp->length = 0;
}
break;
}