From owner-svn-src-all@FreeBSD.ORG Wed May 7 21:38:34 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4A21EED7; Wed, 7 May 2014 21:38:34 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1CD1715F; Wed, 7 May 2014 21:38:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s47LcXbD000606; Wed, 7 May 2014 21:38:33 GMT (envelope-from gavin@svn.freebsd.org) Received: (from gavin@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s47LcXCG000604; Wed, 7 May 2014 21:38:33 GMT (envelope-from gavin@svn.freebsd.org) Message-Id: <201405072138.s47LcXCG000604@svn.freebsd.org> From: Gavin Atkinson Date: Wed, 7 May 2014 21:38:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r265614 - stable/10/sys/dev/an X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 May 2014 21:38:34 -0000 Author: gavin Date: Wed May 7 21:38:33 2014 New Revision: 265614 URL: http://svnweb.freebsd.org/changeset/base/265614 Log: Merge r259393 from head: Fix several panics when initialization of an ISA or PC-CARD device fails: o Assign sc->an_dev in an_probe() (which isn't really a probe function in the standard newbus sense) as we may need it for printing errors. o Use device_printf() rather than if_printf() in an_reset() - this is called from an_probe() long before the ifp structure is initialised in an_attach(). o Initialize the ifp structure early in an_attach() as we use if_printf() in cases where allocation of descriptors etc fails. Modified: stable/10/sys/dev/an/if_an.c stable/10/sys/dev/an/if_an_pccard.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/an/if_an.c ============================================================================== --- stable/10/sys/dev/an/if_an.c Wed May 7 21:16:47 2014 (r265613) +++ stable/10/sys/dev/an/if_an.c Wed May 7 21:38:33 2014 (r265614) @@ -357,6 +357,7 @@ an_probe(device_t dev) CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), 0); CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), 0xFFFF); + sc->an_dev = dev; mtx_init(&sc->an_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, MTX_DEF); AN_LOCK(sc); @@ -685,6 +686,9 @@ an_attach(struct an_softc *sc, int flags device_printf(sc->an_dev, "can not if_alloc()\n"); goto fail; } + ifp->if_softc = sc; + if_initname(ifp, device_get_name(sc->an_dev), + device_get_unit(sc->an_dev)); sc->an_gone = 0; sc->an_associated = 0; @@ -758,9 +762,6 @@ an_attach(struct an_softc *sc, int flags #endif AN_UNLOCK(sc); - ifp->if_softc = sc; - if_initname(ifp, device_get_name(sc->an_dev), - device_get_unit(sc->an_dev)); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = an_ioctl; ifp->if_start = an_start; @@ -1387,7 +1388,7 @@ an_reset(struct an_softc *sc) an_cmd(sc, AN_CMD_NOOP2, 0); if (an_cmd(sc, AN_CMD_FORCE_SYNCLOSS, 0) == ETIMEDOUT) - if_printf(sc->an_ifp, "reset failed\n"); + device_printf(sc->an_dev, "reset failed\n"); an_cmd(sc, AN_CMD_DISABLE, 0); Modified: stable/10/sys/dev/an/if_an_pccard.c ============================================================================== --- stable/10/sys/dev/an/if_an_pccard.c Wed May 7 21:16:47 2014 (r265613) +++ stable/10/sys/dev/an/if_an_pccard.c Wed May 7 21:38:33 2014 (r265614) @@ -141,8 +141,6 @@ an_pccard_attach(device_t dev) an_alloc_irq(dev, sc->irq_rid, 0); - sc->an_dev = dev; - error = an_attach(sc, flags); if (error) goto fail;