Module Name:    src
Committed By:   maxv
Date:           Sun Jan 14 16:18:11 UTC 2018

Modified Files:
        src/sys/netinet: ip_encap.c

Log Message:
Fix memory leak, found by Mootja.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/netinet/ip_encap.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/netinet/ip_encap.c
diff -u src/sys/netinet/ip_encap.c:1.66 src/sys/netinet/ip_encap.c:1.67
--- src/sys/netinet/ip_encap.c:1.66	Wed Nov 15 10:42:41 2017
+++ src/sys/netinet/ip_encap.c	Sun Jan 14 16:18:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_encap.c,v 1.66 2017/11/15 10:42:41 knakahara Exp $	*/
+/*	$NetBSD: ip_encap.c,v 1.67 2018/01/14 16:18:11 maxv Exp $	*/
 /*	$KAME: ip_encap.c,v 1.73 2001/10/02 08:30:58 itojun Exp $	*/
 
 /*
@@ -68,7 +68,7 @@
 #define USE_RADIX
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.66 2017/11/15 10:42:41 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.67 2018/01/14 16:18:11 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mrouting.h"
@@ -822,7 +822,7 @@ encap_attach_func(int af, int proto,
 
 	error = encap_add(ep);
 	if (error)
-		goto fail;
+		goto gc;
 
 	error = 0;
 #ifndef ENCAP_MPSAFE
@@ -830,6 +830,8 @@ encap_attach_func(int af, int proto,
 #endif
 	return ep;
 
+gc:
+	kmem_free(ep, sizeof(*ep));
 fail:
 #ifndef ENCAP_MPSAFE
 	splx(s);

Reply via email to