Source-Changes-HG archive

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

[src/trunk]: src/sys/net ifp->if_transmit() must free mbuf even if error occu...



details:   https://anonhg.NetBSD.org/src/rev/fbcec08f1bca
branches:  trunk
changeset: 822246:fbcec08f1bca
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Thu Mar 09 09:57:36 2017 +0000

description:
ifp->if_transmit() must free mbuf even if error occurred.

Add missing m_freem(m) to if_nulltransmit().
Below ifp->if_transmit() implementations are already added m_freem(m) properly.
    - wm(4)
    - ixg(4)
    - ixv(4)
    - pppoe(4)
    - gif(4)
    - l2tp(4)

pointed out by ozaki-r@n.o, thanks.

diffstat:

 sys/net/if.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (38 lines):

diff -r ba8ca8e6a31e -r fbcec08f1bca sys/net/if.c
--- a/sys/net/if.c      Thu Mar 09 08:41:56 2017 +0000
+++ b/sys/net/if.c      Thu Mar 09 09:57:36 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.382 2017/03/07 01:32:03 ozaki-r Exp $ */
+/*     $NetBSD: if.c,v 1.383 2017/03/09 09:57:36 knakahara Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.382 2017/03/07 01:32:03 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.383 2017/03/09 09:57:36 knakahara Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -379,6 +379,7 @@
 if_nulltransmit(struct ifnet *ifp, struct mbuf *m)
 {
 
+       m_freem(m);
        return ENXIO;
 }
 
@@ -3260,9 +3261,11 @@
        } else {
                KERNEL_UNLOCK_ONE(NULL);
                error = (*ifp->if_transmit)(ifp, m);
+               /* mbuf is alredy freed */
        }
 #else /* !ALTQ */
        error = (*ifp->if_transmit)(ifp, m);
+       /* mbuf is alredy freed */
 #endif /* !ALTQ */
 
        return error;



Home | Main Index | Thread Index | Old Index