Fix locking issues found by Coverity scanning the usrsctp library.

MFC after:	3 days
This commit is contained in:
Michael Tuexen 2017-09-09 20:44:56 +00:00
parent 834214a023
commit f55c326691
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=323376

View File

@ -1959,6 +1959,7 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error);
} else {
id->assoc_value = stcb->asoc.vrf_id;
SCTP_TCB_UNLOCK(stcb);
*optsize = sizeof(struct sctp_assoc_value);
}
break;
@ -3063,7 +3064,6 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
if (event_type > 0) {
if (stcb) {
event->se_on = sctp_stcb_is_feature_on(inp, stcb, event_type);
SCTP_TCB_UNLOCK(stcb);
} else {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL) ||
@ -3077,6 +3077,9 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
}
}
}
if (stcb != NULL) {
SCTP_TCB_UNLOCK(stcb);
}
if (error == 0) {
*optsize = sizeof(struct sctp_event);
}
@ -3647,12 +3650,16 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
sprstat->sprstat_abandoned_unsent = stcb->asoc.strmout[sid].abandoned_unsent[0];
sprstat->sprstat_abandoned_sent = stcb->asoc.strmout[sid].abandoned_sent[0];
#endif
SCTP_TCB_UNLOCK(stcb);
*optsize = sizeof(struct sctp_prstatus);
} else {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
error = EINVAL;
}
if (stcb != NULL) {
SCTP_TCB_UNLOCK(stcb);
}
if (error == 0) {
*optsize = sizeof(struct sctp_prstatus);
}
break;
}
case SCTP_PR_ASSOC_STATUS:
@ -3675,12 +3682,16 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize,
sprstat->sprstat_abandoned_unsent = stcb->asoc.abandoned_unsent[policy];
sprstat->sprstat_abandoned_sent = stcb->asoc.abandoned_sent[policy];
}
SCTP_TCB_UNLOCK(stcb);
*optsize = sizeof(struct sctp_prstatus);
} else {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
error = EINVAL;
}
if (stcb != NULL) {
SCTP_TCB_UNLOCK(stcb);
}
if (error == 0) {
*optsize = sizeof(struct sctp_prstatus);
}
break;
}
case SCTP_MAX_CWND: