From owner-svn-src-stable@FreeBSD.ORG Wed Jan 14 22:10:51 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B66F3106567A; Wed, 14 Jan 2009 22:10:51 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A39A58FC16; Wed, 14 Jan 2009 22:10:51 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0EMApeJ055450; Wed, 14 Jan 2009 22:10:51 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0EMAptA055448; Wed, 14 Jan 2009 22:10:51 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <200901142210.n0EMAptA055448@svn.freebsd.org> From: Marius Strobl Date: Wed, 14 Jan 2009 22:10:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187249 - in stable/7/sys: . contrib/pf dev/cxgb dev/dcons X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jan 2009 22:10:53 -0000 Author: marius Date: Wed Jan 14 22:10:51 2009 New Revision: 187249 URL: http://svn.freebsd.org/changeset/base/187249 Log: MFC: r186876 Check the return values of contigmalloc(9) as well as bus_dma(9) functions and stop attaching of dcons(4) and dcons_crom(4) if they indicate failure. This fixes a panic seen on sparc64 machines with no free physical memory in the requested 32-bit region but still doesn't make dcons(4)/dcons_crom(4) these work. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/dev/dcons/dcons_crom.c stable/7/sys/dev/dcons/dcons_os.c Modified: stable/7/sys/dev/dcons/dcons_crom.c ============================================================================== --- stable/7/sys/dev/dcons/dcons_crom.c Wed Jan 14 22:05:51 2009 (r187248) +++ stable/7/sys/dev/dcons/dcons_crom.c Wed Jan 14 22:10:51 2009 (r187249) @@ -205,7 +205,10 @@ dcons_crom_attach(device_t dev) return (-1); #else struct dcons_crom_softc *sc; + int error; + if (dcons_conf->buf == NULL) + return (ENXIO); sc = (struct dcons_crom_softc *) device_get_softc(dev); sc->fd.fc = device_get_ivars(dev); sc->fd.dev = dev; @@ -213,7 +216,7 @@ dcons_crom_attach(device_t dev) sc->fd.post_busreset = (void *) dcons_crom_post_busreset; /* map dcons buffer */ - bus_dma_tag_create( + error = bus_dma_tag_create( /*parent*/ sc->fd.fc->dmat, /*alignment*/ sizeof(u_int32_t), /*boundary*/ 0, @@ -229,10 +232,16 @@ dcons_crom_attach(device_t dev) /*lockarg*/&Giant, #endif &sc->dma_tag); - bus_dmamap_create(sc->dma_tag, BUS_DMA_COHERENT, &sc->dma_map); - bus_dmamap_load(sc->dma_tag, sc->dma_map, + if (error != 0) + return (error); + error = bus_dmamap_create(sc->dma_tag, BUS_DMA_COHERENT, &sc->dma_map); + if (error != 0) + return (error); + error = bus_dmamap_load(sc->dma_tag, sc->dma_map, (void *)dcons_conf->buf, dcons_conf->size, dmamap_cb, sc, 0); + if (error != 0) + return (error); sc->ehand = EVENTHANDLER_REGISTER(dcons_poll, dcons_crom_poll, (void *)sc, 0); return (0); Modified: stable/7/sys/dev/dcons/dcons_os.c ============================================================================== --- stable/7/sys/dev/dcons/dcons_os.c Wed Jan 14 22:05:51 2009 (r187248) +++ stable/7/sys/dev/dcons/dcons_os.c Wed Jan 14 22:10:51 2009 (r187249) @@ -557,6 +557,8 @@ dcons_drv_init(int stage) */ dg.buf = (struct dcons_buf *) contigmalloc(dg.size, M_DEVBUF, 0, 0x10000, 0xffffffff, PAGE_SIZE, 0ul); + if (dg.buf == NULL) + return (-1); dcons_init(dg.buf, dg.size, sc); } @@ -680,9 +682,9 @@ dcons_modevent(module_t mode, int type, switch (type) { case MOD_LOAD: ret = dcons_drv_init(1); - dcons_attach(); #if __FreeBSD_version >= 500000 if (ret == 0) { + dcons_attach(); dcons_cnprobe(&dcons_consdev); dcons_cninit(&dcons_consdev); cnadd(&dcons_consdev); @@ -691,24 +693,26 @@ dcons_modevent(module_t mode, int type, break; case MOD_UNLOAD: printf("dcons: unload\n"); - callout_stop(&dcons_callout); + if (drv_init == 1) { + callout_stop(&dcons_callout); #if __FreeBSD_version < 502122 #if defined(DDB) && DCONS_FORCE_GDB #if CONS_NODEV - gdb_arg = NULL; + gdb_arg = NULL; #else - gdbdev = NULL; + gdbdev = NULL; #endif #endif #endif #if __FreeBSD_version >= 500000 - cnremove(&dcons_consdev); + cnremove(&dcons_consdev); #endif - dcons_detach(DCONS_CON); - dcons_detach(DCONS_GDB); - dg.buf->magic = 0; + dcons_detach(DCONS_CON); + dcons_detach(DCONS_GDB); + dg.buf->magic = 0; - contigfree(dg.buf, DCONS_BUF_SIZE, M_DEVBUF); + contigfree(dg.buf, DCONS_BUF_SIZE, M_DEVBUF); + } break; case MOD_SHUTDOWN: