git: c05bf58603b0 - stable/13 - sctp: fix FCFS stream scheduler

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Tue, 22 Feb 2022 22:51:53 UTC
The branch stable/13 has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=c05bf58603b0ddfb532636e12538925f1cb022c5

commit c05bf58603b0ddfb532636e12538925f1cb022c5
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2021-09-19 09:56:26 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2022-02-22 22:51:26 +0000

    sctp: fix FCFS stream scheduler
    
    Reported by:    syzbot+c6793f0f0ce698bce230@syzkaller.appspotmail.com
    
    (cherry picked from commit e19d93b19dce276bdf178bb6a449728238d1c6f8)
---
 sys/netinet/sctp_ss_functions.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/sys/netinet/sctp_ss_functions.c b/sys/netinet/sctp_ss_functions.c
index 5557015cd2a9..0a5a788428bc 100644
--- a/sys/netinet/sctp_ss_functions.c
+++ b/sys/netinet/sctp_ss_functions.c
@@ -809,23 +809,22 @@ sctp_ss_fcfs_init(struct sctp_tcb *stcb, struct sctp_association *asoc,
 
 static void
 sctp_ss_fcfs_clear(struct sctp_tcb *stcb, struct sctp_association *asoc,
-    int clear_values, int holds_lock)
+    int clear_values SCTP_UNUSED, int holds_lock)
 {
 	struct sctp_stream_queue_pending *sp;
 
-	if (clear_values) {
-		if (holds_lock == 0) {
-			SCTP_TCB_SEND_LOCK(stcb);
-		}
-		while (!TAILQ_EMPTY(&asoc->ss_data.out.list)) {
-			sp = TAILQ_FIRST(&asoc->ss_data.out.list);
-			TAILQ_REMOVE(&asoc->ss_data.out.list, sp, ss_next);
-			sp->ss_next.tqe_next = NULL;
-			sp->ss_next.tqe_prev = NULL;
-		}
-		if (holds_lock == 0) {
-			SCTP_TCB_SEND_UNLOCK(stcb);
-		}
+	if (holds_lock == 0) {
+		SCTP_TCB_SEND_LOCK(stcb);
+	}
+	while (!TAILQ_EMPTY(&asoc->ss_data.out.list)) {
+		sp = TAILQ_FIRST(&asoc->ss_data.out.list);
+		TAILQ_REMOVE(&asoc->ss_data.out.list, sp, ss_next);
+		sp->ss_next.tqe_next = NULL;
+		sp->ss_next.tqe_prev = NULL;
+	}
+	asoc->ss_data.last_out_stream = NULL;
+	if (holds_lock == 0) {
+		SCTP_TCB_SEND_UNLOCK(stcb);
 	}
 	return;
 }