Source-Changes-HG archive

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

[src/netbsd-2-0]: src/sys/netinet Pull up revision 1.11 (requested by tron in...



details:   https://anonhg.NetBSD.org/src/rev/7bef6eb6fb41
branches:  netbsd-2-0
changeset: 561464:7bef6eb6fb41
user:      grant <grant%NetBSD.org@localhost>
date:      Fri Jun 18 10:07:37 2004 +0000

description:
Pull up revision 1.11 (requested by tron in ticket #501):

Don't leak mbuf if ipfr_fastroute6() fails.

diffstat:

 sys/netinet/ip_fil_netbsd.c |  23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diffs (68 lines):

diff -r 13b7dd541d72 -r 7bef6eb6fb41 sys/netinet/ip_fil_netbsd.c
--- a/sys/netinet/ip_fil_netbsd.c       Fri Jun 18 10:01:29 2004 +0000
+++ b/sys/netinet/ip_fil_netbsd.c       Fri Jun 18 10:07:37 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_fil_netbsd.c,v 1.3.2.6 2004/05/30 11:26:36 tron Exp $       */
+/*     $NetBSD: ip_fil_netbsd.c,v 1.3.2.7 2004/06/18 10:07:37 grant Exp $      */
 
 /*
  * Copyright (C) 1993-2003 by Darren Reed.
@@ -905,8 +905,6 @@
                        return -1;
 
                MCLGET(m, M_DONTWAIT);
-               if (m == NULL)
-                       return -1;
                avail = (m->m_flags & M_EXT) ? MCLBYTES : MHLEN;
                xtra = MIN(fin->fin_plen,
                           avail - hlen - sizeof(*icmp) - max_linkhdr);
@@ -932,7 +930,7 @@
        iclen += xtra;
        m->m_pkthdr.len = iclen;
        if (avail < 0) {
-               m_freem(m);
+               FREE_MB_T(m);
                return -1;
        }
        m->m_len = iclen;
@@ -1033,8 +1031,14 @@
        }
 #endif
 #ifdef USE_INET6
-       if (fin->fin_v == 6)
-               return ipfr_fastroute6(m0, mpp, fin, fdp);
+       if (fin->fin_v == 6) {
+               error = ipfr_fastroute6(m0, mpp, fin, fdp);
+               if ((error != 0) && (*mpp != NULL)) {
+                       FREE_MB_T(*mpp);
+                       *mpp = NULL;
+               }
+               return error;
+       }
 #endif
 
        hlen = fin->fin_hlen;
@@ -1182,6 +1186,7 @@
                MGET(m, M_DONTWAIT, MT_HEADER);
 #endif
                if (m == 0) {
+                       m = m0;
                        error = ENOBUFS;
                        goto bad;
                }
@@ -1327,11 +1332,13 @@
                        dst6 = (struct sockaddr_in6 *)ro->ro_rt->rt_gateway;
                ro->ro_rt->rt_use++;
 
-               if (m0->m_pkthdr.len <= mtu)
+               if (m0->m_pkthdr.len <= mtu) {
+                       *mpp = NULL;
                        error = nd6_output(ifp, fin->fin_ifp, m0,
                                                   dst6, ro->ro_rt);
-               else
+               } else {
                        error = EMSGSIZE;
+               }
        }
 
 bad:



Home | Main Index | Thread Index | Old Index