Author: tuexen
Date: Sat Apr  7 17:38:38 2018
New Revision: 332185
URL: https://svnweb.freebsd.org/changeset/base/332185

Log:
  MFC r323376:
  
  Fix locking issues found by Coverity scanning the usrsctp library.

Modified:
  stable/11/sys/netinet/sctp_usrreq.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netinet/sctp_usrreq.c
==============================================================================
--- stable/11/sys/netinet/sctp_usrreq.c Sat Apr  7 17:36:53 2018        
(r332184)
+++ stable/11/sys/netinet/sctp_usrreq.c Sat Apr  7 17:38:38 2018        
(r332185)
@@ -1959,6 +1959,7 @@ flags_out:
                                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 @@ flags_out:
                        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 @@ flags_out:
                                        }
                                }
                        }
+                       if (stcb != NULL) {
+                               SCTP_TCB_UNLOCK(stcb);
+                       }
                        if (error == 0) {
                                *optsize = sizeof(struct sctp_event);
                        }
@@ -3647,12 +3650,16 @@ flags_out:
                                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,11 +3682,15 @@ flags_out:
                                        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;
                }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to