Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netipsec Fix error handling of MCLGET in key_alloc_mbuf



details:   https://anonhg.NetBSD.org/src/rev/c97bb7fc6557
branches:  trunk
changeset: 827977:c97bb7fc6557
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Tue Nov 21 06:51:54 2017 +0000

description:
Fix error handling of MCLGET in key_alloc_mbuf

diffstat:

 sys/netipsec/key.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r 7ccd1885c4fc -r c97bb7fc6557 sys/netipsec/key.c
--- a/sys/netipsec/key.c        Tue Nov 21 06:49:56 2017 +0000
+++ b/sys/netipsec/key.c        Tue Nov 21 06:51:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: key.c,v 1.236 2017/11/21 06:49:56 ozaki-r Exp $        */
+/*     $NetBSD: key.c,v 1.237 2017/11/21 06:51:54 ozaki-r Exp $        */
 /*     $FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $        */
 /*     $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $   */
 
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.236 2017/11/21 06:49:56 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.237 2017/11/21 06:51:54 ozaki-r Exp $");
 
 /*
  * This code is referred to RFC 2367
@@ -8352,8 +8352,13 @@
        len = l;
        while (len > 0) {
                MGET(n, M_DONTWAIT, MT_DATA);
-               if (n && len > MLEN)
+               if (n && len > MLEN) {
                        MCLGET(n, M_DONTWAIT);
+                       if ((n->m_flags & M_EXT) == 0) {
+                               m_freem(n);
+                               n = NULL;
+                       }
+               }
                if (!n) {
                        m_freem(m);
                        return NULL;



Home | Main Index | Thread Index | Old Index