Do not try to deallocate memory that wasn't allocated (you'd think that
would be safe, but the function also tries to destroy mutexes that never got created). I guess this can only happen when imx_ehci_detach() is called on the error-exit path from imx_ehci_attach(), and that path never got exercised before today.
This commit is contained in:
parent
9a323f25ab
commit
47d67d2451
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329479
@ -268,6 +268,7 @@ struct imx_ehci_softc {
|
||||
device_t dev;
|
||||
struct resource *ehci_mem_res; /* EHCI core regs. */
|
||||
struct resource *ehci_irq_res; /* EHCI core IRQ. */
|
||||
bool usb_mem_allocated;
|
||||
};
|
||||
|
||||
static struct ofw_compat_data compat_data[] = {
|
||||
@ -331,7 +332,8 @@ imx_ehci_detach(device_t dev)
|
||||
bus_release_resource(dev, SYS_RES_MEMORY, 0,
|
||||
sc->ehci_mem_res);
|
||||
|
||||
usb_bus_mem_free_all(&esc->sc_bus, &ehci_iterate_hw_softc);
|
||||
if (sc->usb_mem_allocated)
|
||||
usb_bus_mem_free_all(&esc->sc_bus, &ehci_iterate_hw_softc);
|
||||
|
||||
/* During module unload there are lots of children leftover */
|
||||
device_delete_children(dev);
|
||||
@ -413,6 +415,7 @@ imx_ehci_attach(device_t dev)
|
||||
err = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
sc->usb_mem_allocated = true;
|
||||
|
||||
/*
|
||||
* Set handle to USB related registers subregion used by
|
||||
|
Loading…
Reference in New Issue
Block a user