git: 3d40cc7ab888 - main - sctp: add missing check

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

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

commit 3d40cc7ab888a37a3ba085f377a057396a7d2476
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2024-05-08 21:01:06 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2024-05-08 21:03:34 +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
    MFC after:      3 days
---
 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 a8facff6b917..e0106831f06a 100644
--- a/sys/netinet/sctp_output.c
+++ b/sys/netinet/sctp_output.c
@@ -6705,7 +6705,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;