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

This commit is contained in:
msaitoh 2017-10-23 09:22:24 +00:00
parent eba490a0d2
commit cb49e3c2fa
4 changed files with 22 additions and 13 deletions

View File

@ -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 @@ void bah_reconwatch(void *);
#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 @@ bah_attach_subr(struct bah_softc *sc)
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 @@ bah_attach_subr(struct bah_softc *sc)
#endif
callout_init(&sc->sc_recon_ch, 0);
return 0;
}
/*

View File

@ -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 @@ struct bah_softc {
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

View File

@ -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 @@ struct arccom {
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

View File

@ -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 @@ arc_sprintf(uint8_t *ap)
/*
* 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 @@ arc_ifattach(struct ifnet *ifp, uint8_t lla)
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;
}