Source-Changes-HG archive

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

[src/netbsd-6]: src/sys/net Pull up following revision(s) (requested by knaka...



details:   https://anonhg.NetBSD.org/src/rev/3aa50bdfeb3a
branches:  netbsd-6
changeset: 777022:3aa50bdfeb3a
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Nov 15 21:04:53 2015 +0000

description:
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.
correct mistake in previous

diffstat:

 sys/net/if_gif.c |  46 ++++++++++++++++++++++++++--------------------
 1 files changed, 26 insertions(+), 20 deletions(-)

diffs (94 lines):

diff -r 690e67e0031f -r 3aa50bdfeb3a sys/net/if_gif.c
--- a/sys/net/if_gif.c  Sun Nov 15 21:02:13 2015 +0000
+++ b/sys/net/if_gif.c  Sun Nov 15 21:04:53 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_gif.c,v 1.80.8.1 2013/02/08 20:42:51 riz Exp $      */
+/*     $NetBSD: if_gif.c,v 1.80.8.2 2015/11/15 21:04:53 bouyer 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.8.1 2013/02/08 20:42:51 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.80.8.2 2015/11/15 21:04:53 bouyer Exp $");
 
 #include "opt_inet.h"
 #include "opt_iso.h"
@@ -743,17 +743,24 @@
 #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
@@ -770,33 +777,32 @@
                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



Home | Main Index | Thread Index | Old Index