Module Name:    src
Committed By:   snj
Date:           Fri Aug 11 15:21:38 UTC 2017

Modified Files:
        src/sys/arch/newsmips/apbus [netbsd-7]: if_sn.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1467):
        sys/arch/newsmips/apbus/if_sn.c: revision 1.39
Avoid memory leak in sonic_get.
If this is the first time around, top is null and nothing else will
free m.
>From Ilja Van Sprundel.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.34.12.1 src/sys/arch/newsmips/apbus/if_sn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/newsmips/apbus/if_sn.c
diff -u src/sys/arch/newsmips/apbus/if_sn.c:1.34 src/sys/arch/newsmips/apbus/if_sn.c:1.34.12.1
--- src/sys/arch/newsmips/apbus/if_sn.c:1.34	Sat Oct 13 06:24:15 2012
+++ src/sys/arch/newsmips/apbus/if_sn.c	Fri Aug 11 15:21:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_sn.c,v 1.34 2012/10/13 06:24:15 tsutsui Exp $	*/
+/*	$NetBSD: if_sn.c,v 1.34.12.1 2017/08/11 15:21:38 snj Exp $	*/
 
 /*
  * National Semiconductor  DP8393X SONIC Driver
@@ -16,7 +16,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sn.c,v 1.34 2012/10/13 06:24:15 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sn.c,v 1.34.12.1 2017/08/11 15:21:38 snj Exp $");
 
 #include "opt_inet.h"
 
@@ -1093,7 +1093,10 @@ sonic_get(struct sn_softc *sc, void *pkt
 		if (datalen >= MINCLSIZE) {
 			MCLGET(m, M_DONTWAIT);
 			if ((m->m_flags & M_EXT) == 0) {
-				if (top) m_freem(top);
+				if (top)
+					m_freem(top);
+				else
+					m_freem(m);
 				return 0;
 			}
 			len = MCLBYTES;

Reply via email to