git: 8c37094036a5 - main - sctp: allow stcb == NULL in sctp_shutdown()

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Thu, 09 May 2024 15:49:13 UTC
The branch main has been updated by tuexen:

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

commit 8c37094036a5f00301c5f5f2be475b664dd5ea23
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2024-05-08 22:43:28 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2024-05-08 22:43:28 +0000

    sctp: allow stcb == NULL in sctp_shutdown()
    
    Consistently handle this case.
    Reported by:    Coverity Scan
    CID:            1533813
    MFC after:      3 days
---
 sys/netinet/sctp_usrreq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c
index 3b0da87edce3..b9a3be5280ae 100644
--- a/sys/netinet/sctp_usrreq.c
+++ b/sys/netinet/sctp_usrreq.c
@@ -843,8 +843,10 @@ sctp_shutdown(struct socket *so, enum shutdown_how how)
 				}
 				sctp_free_a_readq(stcb, control);
 			} else {
-				stcb->asoc.size_on_all_streams +=
-				    control->length;
+				if (stcb != NULL) {
+					stcb->asoc.size_on_all_streams +=
+					    control->length;
+				}
 			}
 		}
 		SOCK_UNLOCK(so);