Source-Changes-HG archive

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

[src/trunk]: src/sys/net commonize error handling in pppoe_clone_create()



details:   https://anonhg.NetBSD.org/src/rev/b16dc1ded9ea
branches:  trunk
changeset: 1020559:b16dc1ded9ea
user:      yamaguchi <yamaguchi%NetBSD.org@localhost>
date:      Fri Apr 16 01:24:35 2021 +0000

description:
commonize error handling in pppoe_clone_create()

diffstat:

 sys/net/if_pppoe.c |  27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diffs (62 lines):

diff -r 95d5e88bdc27 -r b16dc1ded9ea sys/net/if_pppoe.c
--- a/sys/net/if_pppoe.c        Fri Apr 16 01:14:38 2021 +0000
+++ b/sys/net/if_pppoe.c        Fri Apr 16 01:24:35 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.162 2021/04/13 05:04:54 yamaguchi Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.163 2021/04/16 01:24:35 yamaguchi Exp $ */
 
 /*
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.162 2021/04/13 05:04:54 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.163 2021/04/16 01:24:35 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pppoe.h"
@@ -367,10 +367,8 @@
        rv = workqueue_create(&sc->sc_timeout_wq,
            sc->sc_sppp.pp_if.if_xname, pppoe_timeout_wk, sc,
            PRI_SOFTNET, IPL_SOFTNET, 0);
-       if (rv != 0) {
-               free(sc, M_DEVBUF);
-               return rv;
-       }
+       if (rv != 0)
+               goto free_sc;
 
        callout_init(&sc->sc_timeout, CALLOUT_MPSAFE);
        callout_setfunc(&sc->sc_timeout, pppoe_timeout_co, sc);
@@ -384,13 +382,9 @@
        sc->sc_sppp.pp_framebytes = PPPOE_HEADERLEN;    /* framing added to ppp packets */
 
        rv = if_initialize(&sc->sc_sppp.pp_if);
-       if (rv != 0) {
-               workqueue_destroy(sc->sc_timeout_wq);
-               callout_halt(&sc->sc_timeout, NULL);
-               callout_destroy(&sc->sc_timeout);
-               free(sc, M_DEVBUF);
-               return rv;
-       }
+       if (rv != 0)
+               goto destroy_timeout;
+
        sc->sc_sppp.pp_if.if_percpuq = if_percpuq_create(&sc->sc_sppp.pp_if);
        sppp_attach(&sc->sc_sppp.pp_if);
 
@@ -409,6 +403,13 @@
        LIST_INSERT_HEAD(&pppoe_softc_list, sc, sc_list);
        rw_exit(&pppoe_softc_list_lock);
        return 0;
+
+destroy_timeout:
+       callout_destroy(&sc->sc_timeout);
+       workqueue_destroy(sc->sc_timeout_wq);
+free_sc:
+       free(sc, M_DEVBUF);
+       return rv;
 }
 
 static int



Home | Main Index | Thread Index | Old Index