Module Name: src Committed By: msaitoh Date: Wed Nov 18 07:36:22 UTC 2015
Modified Files: src/sys/net [netbsd-6-0]: if_gif.c Log Message: Pull up following revision(s) (requested by knakahara in ticket #1344): sys/net/if_gif.c: revision 1.89 sys/net/if_gif.c: revision 1.90 CID 980463: Provide common error path for rollback. Remove extra check for success. To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.80.14.1 src/sys/net/if_gif.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/net/if_gif.c diff -u src/sys/net/if_gif.c:1.80 src/sys/net/if_gif.c:1.80.14.1 --- src/sys/net/if_gif.c:1.80 Fri Oct 28 16:42:52 2011 +++ src/sys/net/if_gif.c Wed Nov 18 07:36:22 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: if_gif.c,v 1.80 2011/10/28 16:42:52 dyoung Exp $ */ +/* $NetBSD: if_gif.c,v 1.80.14.1 2015/11/18 07:36:22 msaitoh 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.80 2011/10/28 16:42:52 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.80.14.1 2015/11/18 07:36:22 msaitoh Exp $"); #include "opt_inet.h" #include "opt_iso.h" @@ -746,17 +746,24 @@ gif_set_tunnel(struct ifnet *ifp, struct #endif } + osrc = sc->gif_psrc; + odst = sc->gif_pdst; + sc->gif_psrc = sc->gif_pdst = NULL; sc->gif_si = softint_establish(SOFTINT_NET, gifintr, sc); if (sc->gif_si == NULL) { error = ENOMEM; - goto bad; + goto rollback; } - osrc = sc->gif_psrc; - sc->gif_psrc = sockaddr_dup(src, M_WAITOK); + if ((sc->gif_psrc = sockaddr_dup(src, M_WAITOK)) == NULL) { + error = ENOMEM; + goto rollback; + } - odst = sc->gif_pdst; - sc->gif_pdst = sockaddr_dup(dst, M_WAITOK); + if ((sc->gif_pdst = sockaddr_dup(dst, M_WAITOK)) == NULL) { + error = ENOMEM; + goto rollback; + } switch (sc->gif_psrc->sa_family) { #ifdef INET @@ -773,33 +780,32 @@ gif_set_tunnel(struct ifnet *ifp, struct error = EINVAL; break; } - if (error) { - /* rollback */ - sockaddr_free(sc->gif_psrc); - sockaddr_free(sc->gif_pdst); - sc->gif_psrc = osrc; - sc->gif_pdst = odst; - goto bad; - } + if (error) + goto rollback; if (osrc) sockaddr_free(osrc); if (odst) sockaddr_free(odst); - if (sc->gif_psrc && sc->gif_pdst) - ifp->if_flags |= IFF_RUNNING; - else - ifp->if_flags &= ~IFF_RUNNING; + ifp->if_flags |= IFF_RUNNING; splx(s); return 0; - bad: +rollback: + if (sc->gif_psrc != NULL) + sockaddr_free(sc->gif_psrc); + if (sc->gif_pdst != NULL) + sockaddr_free(sc->gif_pdst); + sc->gif_psrc = osrc; + sc->gif_pdst = odst; +bad: if (sc->gif_si) { softint_disestablish(sc->gif_si); sc->gif_si = NULL; } + if (sc->gif_psrc && sc->gif_pdst) ifp->if_flags |= IFF_RUNNING; else