Source-Changes-HG archive

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

[src/trunk]: src/sys/net Fix memory leak in vlan_start



details:   https://anonhg.NetBSD.org/src/rev/3d2561a5d69a
branches:  trunk
changeset: 822345:3d2561a5d69a
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Wed Mar 15 09:51:08 2017 +0000

description:
Fix memory leak in vlan_start

diffstat:

 sys/net/if_vlan.c |  24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diffs (47 lines):

diff -r f4598645d089 -r 3d2561a5d69a sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Wed Mar 15 06:40:34 2017 +0000
+++ b/sys/net/if_vlan.c Wed Mar 15 09:51:08 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vlan.c,v 1.95 2017/01/23 06:47:54 ozaki-r Exp $     */
+/*     $NetBSD: if_vlan.c,v 1.96 2017/03/15 09:51:08 ozaki-r Exp $     */
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.95 2017/01/23 06:47:54 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.96 2017/03/15 09:51:08 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -841,19 +841,17 @@
                        }
                }
 
-               /*
-                * Send it, precisely as the parent's output routine
-                * would have.  We are already running at splnet.
-                */
-               if ((p->if_flags & IFF_RUNNING) != 0) {
-                       error = if_transmit_lock(p, m);
-                       if (error) {
-                               /* mbuf is already freed */
-                               ifp->if_oerrors++;
-                               continue;
-                       }
+               if ((p->if_flags & IFF_RUNNING) == 0) {
+                       m_freem(m);
+                       continue;
                }
 
+               error = if_transmit_lock(p, m);
+               if (error) {
+                       /* mbuf is already freed */
+                       ifp->if_oerrors++;
+                       continue;
+               }
                ifp->if_opackets++;
        }
 



Home | Main Index | Thread Index | Old Index