From 6776c7cba92c91bbe5a49de3052461002f496513 Mon Sep 17 00:00:00 2001 From: Jonathan Lemon Date: Sat, 10 Jun 2000 17:55:57 +0000 Subject: [PATCH] Check for MGET* returning NULL and return ENOBUFS in this case. Submitted by: Bosko Milekic --- sys/netkey/keysock.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/netkey/keysock.c b/sys/netkey/keysock.c index b3c8652ec786..f26e8a5dc85f 100644 --- a/sys/netkey/keysock.c +++ b/sys/netkey/keysock.c @@ -419,13 +419,19 @@ key_sendup(so, msg, len, target) while (tlen > 0) { if (tlen == len) { MGETHDR(n, M_DONTWAIT, MT_DATA); + if (n == NULL) { + m_freem(m); + return ENOBUFS; + } n->m_len = MHLEN; } else { MGET(n, M_DONTWAIT, MT_DATA); + if (n == NULL) { + m_freem(m); + return ENOBUFS; + } n->m_len = MLEN; } - if (!n) - return ENOBUFS; if (tlen > MCLBYTES) { /*XXX better threshold? */ MCLGET(n, M_DONTWAIT); if ((n->m_flags & M_EXT) == 0) {