git: 75ee09cf628c - stable/13 - sctp: add missing check

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Thu, 01 Aug 2024 20:57:17 UTC
The branch stable/13 has been updated by tuexen:

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

commit 75ee09cf628c6cfb58a26283fcf1c05b5c97306f
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2024-05-08 21:01:06 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2024-08-01 20:56:27 +0000

    sctp: add missing check
    
    If memory allocation fails, m is NULL. Since this is possible,
    check for it.
    Reported by:    Coverity Scan
    CID:            1086866
    
    (cherry picked from commit 3d40cc7ab888a37a3ba085f377a057396a7d2476)
---
 sys/netinet/sctp_output.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c
index f13010e54521..13a9a65da9eb 100644
--- a/sys/netinet/sctp_output.c
+++ b/sys/netinet/sctp_output.c
@@ -6635,7 +6635,9 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr,
 		} else {
 			m = sctp_get_mbuf_for_msg(sizeof(struct sctp_paramhdr),
 			    0, M_NOWAIT, 1, MT_DATA);
-			SCTP_BUF_LEN(m) = sizeof(struct sctp_paramhdr);
+			if (m != NULL) {
+				SCTP_BUF_LEN(m) = sizeof(struct sctp_paramhdr);
+			}
 		}
 		if (m != NULL) {
 			struct sctp_paramhdr *ph;