Do only call oltr_stop() if we are not already in OL_STOPPED state.
This avoids a null pointer deref panic in TRlldClose() inside the vendor-supplied object code. It's now possible to unload the driver at all. Implement deallocation of malloc()ed memory regions. MFC after: 2 months
This commit is contained in:
parent
cc79317c31
commit
f37de73e2b
@ -439,13 +439,14 @@ oltr_pci_detach(device_t dev)
|
||||
{
|
||||
struct oltr_softc *sc = device_get_softc(dev);
|
||||
struct ifnet *ifp = &sc->arpcom.ac_if;
|
||||
int s;
|
||||
int s, i;
|
||||
|
||||
device_printf(dev, "driver unloading\n");
|
||||
|
||||
s = splimp();
|
||||
|
||||
if_detach(ifp);
|
||||
if (sc->state > OL_CLOSED)
|
||||
oltr_stop(sc);
|
||||
|
||||
untimeout(oltr_poll, (void *)sc, sc->oltr_poll_ch);
|
||||
@ -454,6 +455,15 @@ oltr_pci_detach(device_t dev)
|
||||
bus_teardown_intr(dev, sc->oltr_irq, sc->oltr_intrhand);
|
||||
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->oltr_irq);
|
||||
|
||||
/* Deallocate all dynamic memory regions */
|
||||
for (i = 0; i < RING_BUFFER_LEN; i++) {
|
||||
free(sc->rx_ring[i].data, M_DEVBUF);
|
||||
free(sc->tx_ring[i].data, M_DEVBUF);
|
||||
}
|
||||
if (sc->work_memory)
|
||||
free(sc->work_memory, M_DEVBUF);
|
||||
free(sc->TRlldAdapter, M_DEVBUF);
|
||||
|
||||
(void)splx(s);
|
||||
|
||||
return(0);
|
||||
@ -466,6 +476,7 @@ oltr_pci_shutdown(device_t dev)
|
||||
|
||||
device_printf(dev, "oltr_pci_shutdown called\n");
|
||||
|
||||
if (sc->state > OL_CLOSED)
|
||||
oltr_stop(sc);
|
||||
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user