Source-Changes-HG archive

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

[src/trunk]: src/sys If if_attach() failed in the attach function, return.



details:   https://anonhg.NetBSD.org/src/rev/24a031026754
branches:  trunk
changeset: 827304:24a031026754
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Oct 23 09:22:24 2017 +0000

description:
If if_attach() failed in the attach function, return.

diffstat:

 sys/dev/ic/smc90cx6.c    |  13 ++++++++-----
 sys/dev/ic/smc90cx6var.h |   4 ++--
 sys/net/if_arc.h         |   4 ++--
 sys/net/if_arcsubr.c     |  14 ++++++++++----
 4 files changed, 22 insertions(+), 13 deletions(-)

diffs (135 lines):

diff -r 4828ccf4e970 -r 24a031026754 sys/dev/ic/smc90cx6.c
--- a/sys/dev/ic/smc90cx6.c     Mon Oct 23 09:21:40 2017 +0000
+++ b/sys/dev/ic/smc90cx6.c     Mon Oct 23 09:22:24 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smc90cx6.c,v 1.70 2017/05/23 02:43:13 ozaki-r Exp $ */
+/*     $NetBSD: smc90cx6.c,v 1.71 2017/10/23 09:22:24 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smc90cx6.c,v 1.70 2017/05/23 02:43:13 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smc90cx6.c,v 1.71 2017/10/23 09:22:24 msaitoh Exp $");
 
 /* #define BAHSOFTCOPY */
 #define BAHRETRANSMIT /**/
@@ -140,11 +140,11 @@
 #define GETMEM(off)    bus_space_read_1(bst_m, mem, (off))
 #define PUTMEM(off, v) bus_space_write_1(bst_m, mem, (off), (v))
 
-void
+int
 bah_attach_subr(struct bah_softc *sc)
 {
        struct ifnet *ifp = &sc->sc_arccom.ac_if;
-       int s;
+       int s, rv;
        u_int8_t linkaddress;
 
        bus_space_tag_t bst_r = sc->sc_bst_r;
@@ -197,7 +197,9 @@
 
        ifp->if_mtu = ARCMTU;
 
-       arc_ifattach(ifp, linkaddress);
+       rv = arc_ifattach(ifp, linkaddress);
+       if (rv != 0)
+               return rv;
        if_deferred_start_init(ifp, NULL);
 
 #ifdef BAHSOFTCOPY
@@ -207,6 +209,7 @@
 #endif
 
        callout_init(&sc->sc_recon_ch, 0);
+       return 0;
 }
 
 /*
diff -r 4828ccf4e970 -r 24a031026754 sys/dev/ic/smc90cx6var.h
--- a/sys/dev/ic/smc90cx6var.h  Mon Oct 23 09:21:40 2017 +0000
+++ b/sys/dev/ic/smc90cx6var.h  Mon Oct 23 09:22:24 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smc90cx6var.h,v 1.11 2012/10/27 17:18:22 chs Exp $     */
+/*     $NetBSD: smc90cx6var.h,v 1.12 2017/10/23 09:22:24 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
        u_char  sc_retransmits[2];      /* unused at the moment */
 };
 
-void   bah_attach_subr(struct bah_softc *);
+int    bah_attach_subr(struct bah_softc *);
 int    bahintr(void *);
 
 #endif
diff -r 4828ccf4e970 -r 24a031026754 sys/net/if_arc.h
--- a/sys/net/if_arc.h  Mon Oct 23 09:21:40 2017 +0000
+++ b/sys/net/if_arc.h  Mon Oct 23 09:22:24 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arc.h,v 1.22 2008/02/20 17:05:52 matt Exp $ */
+/*     $NetBSD: if_arc.h,v 1.23 2017/10/23 09:22:24 msaitoh Exp $      */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -118,7 +118,7 @@
 extern uint8_t arcbroadcastaddr;
 extern int arc_ipmtu;  /* XXX new ip only, no RFC 1051! */
 
-void   arc_ifattach(struct ifnet *, uint8_t);
+int    arc_ifattach(struct ifnet *, uint8_t);
 char   *arc_sprintf(uint8_t *);
 int    arc_isphds(uint8_t);
 #endif
diff -r 4828ccf4e970 -r 24a031026754 sys/net/if_arcsubr.c
--- a/sys/net/if_arcsubr.c      Mon Oct 23 09:21:40 2017 +0000
+++ b/sys/net/if_arcsubr.c      Mon Oct 23 09:22:24 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arcsubr.c,v 1.77 2017/02/14 03:05:06 ozaki-r Exp $  */
+/*     $NetBSD: if_arcsubr.c,v 1.78 2017/10/23 09:22:24 msaitoh Exp $  */
 
 /*
  * Copyright (c) 1994, 1995 Ignatios Souvatzis
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.77 2017/02/14 03:05:06 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.78 2017/10/23 09:22:24 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -610,10 +610,11 @@
 /*
  * Perform common duties while attaching to interface list
  */
-void
+int
 arc_ifattach(struct ifnet *ifp, uint8_t lla)
 {
        struct arccom *ac;
+       int rv;
 
        ifp->if_type = IFT_ARCNET;
        ifp->if_addrlen = 1;
@@ -635,10 +636,15 @@
                log(LOG_ERR,"%s: link address 0 reserved for broadcasts.  Please change it and ifconfig %s down up\n",
                   ifp->if_xname, ifp->if_xname);
        }
-       if_attach(ifp);
+       rv = if_attach(ifp);
+       if (rv != 0)
+               return rv;
+
        if_set_sadl(ifp, &lla, sizeof(lla), true);
 
        ifp->if_broadcastaddr = &arcbroadcastaddr;
 
        bpf_attach(ifp, DLT_ARCNET, ARC_HDRLEN);
+
+       return 0;
 }



Home | Main Index | Thread Index | Old Index