Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Check whether sc->bge_dmatag != NULL or not. Fix...



details:   https://anonhg.NetBSD.org/src/rev/414f7453aaf4
branches:  trunk
changeset: 786647:414f7453aaf4
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Sun May 05 11:28:34 2013 +0000

description:
Check whether sc->bge_dmatag != NULL or not. Fix a bug that
bge_release_resources() panics when bge_attach failed.

diffstat:

 sys/dev/pci/if_bge.c |  16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diffs (37 lines):

diff -r 045bb41ae5e0 -r 414f7453aaf4 sys/dev/pci/if_bge.c
--- a/sys/dev/pci/if_bge.c      Sun May 05 10:40:19 2013 +0000
+++ b/sys/dev/pci/if_bge.c      Sun May 05 11:28:34 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bge.c,v 1.238 2013/04/21 19:59:40 msaitoh Exp $     */
+/*     $NetBSD: if_bge.c,v 1.239 2013/05/05 11:28:34 msaitoh Exp $     */
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.238 2013/04/21 19:59:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.239 2013/05/05 11:28:34 msaitoh Exp $");
 
 #include "vlan.h"
 
@@ -3912,11 +3912,13 @@
                sc->bge_intrhand = NULL;
        }
 
-       bus_dmamap_unload(sc->bge_dmatag, sc->bge_ring_map);
-       bus_dmamap_destroy(sc->bge_dmatag, sc->bge_ring_map);
-       bus_dmamem_unmap(sc->bge_dmatag, (void *)sc->bge_rdata,
-           sizeof(struct bge_ring_data));
-       bus_dmamem_free(sc->bge_dmatag, &sc->bge_ring_seg, sc->bge_ring_rseg);
+       if (sc->bge_dmatag != NULL) {
+               bus_dmamap_unload(sc->bge_dmatag, sc->bge_ring_map);
+               bus_dmamap_destroy(sc->bge_dmatag, sc->bge_ring_map);
+               bus_dmamem_unmap(sc->bge_dmatag, (void *)sc->bge_rdata,
+                   sizeof(struct bge_ring_data));
+               bus_dmamem_free(sc->bge_dmatag, &sc->bge_ring_seg, sc->bge_ring_rseg);
+       }
 
        /* Unmap the device registers */
        if (sc->bge_bsize != 0) {



Home | Main Index | Thread Index | Old Index