bge: Avoid accessing invalid internal memory region on BCM5906
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 2 Jul 2012 07:12:20 +0000 (15:12 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Mon, 2 Jul 2012 08:46:01 +0000 (16:46 +0800)
Obtained-from: FreeBSD 213747

sys/dev/netif/bge/if_bge.c

index 33d707a..21ea0f2 100644 (file)
@@ -437,6 +437,10 @@ bge_readmem_ind(struct bge_softc *sc, uint32_t off)
        device_t dev = sc->bge_dev;
        uint32_t val;
 
+       if (sc->bge_asicrev == BGE_ASICREV_BCM5906 &&
+           off >= BGE_STATS_BLOCK && off < BGE_SEND_RING_1_TO_4)
+               return 0;
+
        pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, off, 4);
        val = pci_read_config(dev, BGE_PCI_MEMWIN_DATA, 4);
        pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, 0, 4);
@@ -448,6 +452,10 @@ bge_writemem_ind(struct bge_softc *sc, uint32_t off, uint32_t val)
 {
        device_t dev = sc->bge_dev;
 
+       if (sc->bge_asicrev == BGE_ASICREV_BCM5906 &&
+           off >= BGE_STATS_BLOCK && off < BGE_SEND_RING_1_TO_4)
+               return;
+
        pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, off, 4);
        pci_write_config(dev, BGE_PCI_MEMWIN_DATA, val, 4);
        pci_write_config(dev, BGE_PCI_MEMWIN_BASEADDR, 0, 4);