Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/net Pull up following revision(s) (requested by knaka...
details: https://anonhg.NetBSD.org/src/rev/0d4c6eadc523
branches: netbsd-8
changeset: 434203:0d4c6eadc523
user: snj <snj%NetBSD.org@localhost>
date: Wed Aug 09 05:51:50 2017 +0000
description:
Pull up following revision(s) (requested by knakahara in ticket #201):
sys/net/if_gif.c: revision 1.128
fix leak when encap_attach() fails twice.
diffstat:
sys/net/if_gif.c | 47 +++++++++++++++++++++++++----------------------
1 files changed, 25 insertions(+), 22 deletions(-)
diffs (73 lines):
diff -r 5b196d25e798 -r 0d4c6eadc523 sys/net/if_gif.c
--- a/sys/net/if_gif.c Wed Aug 09 05:49:50 2017 +0000
+++ b/sys/net/if_gif.c Wed Aug 09 05:51:50 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gif.c,v 1.126.2.1 2017/06/30 06:17:51 snj Exp $ */
+/* $NetBSD: if_gif.c,v 1.126.2.2 2017/08/09 05:51:50 snj Exp $ */
/* $KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.126.2.1 2017/06/30 06:17:51 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.126.2.2 2017/08/09 05:51:50 snj Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -997,31 +997,34 @@
/*
* Secondly, try to set new configurations.
- * If the setup failed, rollback to old configurations.
*/
- do {
- osrc = sc->gif_psrc;
- odst = sc->gif_pdst;
- sc->gif_psrc = nsrc;
- sc->gif_pdst = ndst;
-
+ osrc = sc->gif_psrc;
+ odst = sc->gif_pdst;
+ sc->gif_psrc = nsrc;
+ sc->gif_pdst = ndst;
+ error = gif_encap_attach(sc);
+ if (error && osrc != NULL && odst != NULL) {
+ /*
+ * Thirdly, when error occured, rollback to old configurations,
+ * if last setting is valid.
+ */
+ sc->gif_psrc = osrc;
+ sc->gif_pdst = odst;
+ osrc = nsrc; /* to free */
+ odst = ndst; /* to free */
error = gif_encap_attach(sc);
- if (error) {
- /* rollback to the last configuration. */
- nsrc = osrc;
- ndst = odst;
- osrc = sc->gif_psrc;
- odst = sc->gif_pdst;
-
- continue;
- }
- } while (error != 0 && (nsrc != NULL && ndst != NULL));
- /* Thirdly, even rollback failed, clear configurations. */
+ }
if (error) {
- osrc = sc->gif_psrc;
- odst = sc->gif_pdst;
+ /*
+ * Fourthly, even rollback failed or last setting is not valid,
+ * clear configurations.
+ */
+ osrc = sc->gif_psrc; /* to free */
+ odst = sc->gif_pdst; /* to free */
sc->gif_psrc = NULL;
sc->gif_pdst = NULL;
+ sockaddr_free(nsrc);
+ sockaddr_free(ndst);
}
if (osrc)
Home |
Main Index |
Thread Index |
Old Index