diff options
author | hselasky <hselasky@FreeBSD.org> | 2016-11-07 08:36:06 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2016-11-07 08:36:06 +0000 |
commit | ea512fc24698cb90f6b4456e0a76fba1ca994e3a (patch) | |
tree | 54be7a70e07f49ecc9474f9c6f165a7812292e09 /sys/mips/mediatek | |
parent | 7fa1d4ac3f1e9c0244c9fea96875bb5b6b0bc8ce (diff) | |
download | FreeBSD-src-ea512fc24698cb90f6b4456e0a76fba1ca994e3a.zip FreeBSD-src-ea512fc24698cb90f6b4456e0a76fba1ca994e3a.tar.gz |
MFC r307518:
Fix device delete child function.
When detaching device trees parent devices must be detached prior to
detaching its children. This is because parent devices can have
pointers to the child devices in their softcs which are not
invalidated by device_delete_child(). This can cause use after free
issues and panic().
Device drivers implementing trees, must ensure its detach function
detaches or deletes all its children before returning.
While at it remove now redundant device_detach() calls before
device_delete_child() and device_delete_children(), mostly in
the USB controller drivers.
Tested by: Jan Henrik Sylvester <me@janh.de>
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D8070
Diffstat (limited to 'sys/mips/mediatek')
-rw-r--r-- | sys/mips/mediatek/mtk_dotg.c | 6 | ||||
-rw-r--r-- | sys/mips/mediatek/mtk_ehci.c | 6 | ||||
-rw-r--r-- | sys/mips/mediatek/mtk_ohci.c | 6 | ||||
-rw-r--r-- | sys/mips/mediatek/mtk_xhci.c | 6 |
4 files changed, 0 insertions, 24 deletions
diff --git a/sys/mips/mediatek/mtk_dotg.c b/sys/mips/mediatek/mtk_dotg.c index d7421ad..e685eac 100644 --- a/sys/mips/mediatek/mtk_dotg.c +++ b/sys/mips/mediatek/mtk_dotg.c @@ -161,14 +161,8 @@ static int dotg_fdt_detach(device_t dev) { struct dwc_otg_softc *sc = device_get_softc(dev); - device_t bdev; int err; - if (sc->sc_bus.bdev) { - bdev = sc->sc_bus.bdev; - device_detach(bdev); - device_delete_child(dev, bdev); - } /* during module unload there are lots of children leftover */ device_delete_children(dev); diff --git a/sys/mips/mediatek/mtk_ehci.c b/sys/mips/mediatek/mtk_ehci.c index acc30eb..ed1d2fc 100644 --- a/sys/mips/mediatek/mtk_ehci.c +++ b/sys/mips/mediatek/mtk_ehci.c @@ -162,14 +162,8 @@ static int ehci_fdt_detach(device_t self) { ehci_softc_t *sc = device_get_softc(self); - device_t bdev; int err; - if (sc->sc_bus.bdev) { - bdev = sc->sc_bus.bdev; - device_detach(bdev); - device_delete_child(self, bdev); - } /* during module unload there are lots of children leftover */ device_delete_children(self); diff --git a/sys/mips/mediatek/mtk_ohci.c b/sys/mips/mediatek/mtk_ohci.c index 0b554e7..ad5c68f 100644 --- a/sys/mips/mediatek/mtk_ohci.c +++ b/sys/mips/mediatek/mtk_ohci.c @@ -162,14 +162,8 @@ static int ohci_fdt_detach(device_t self) { ohci_softc_t *sc = device_get_softc(self); - device_t bdev; int err; - if (sc->sc_bus.bdev) { - bdev = sc->sc_bus.bdev; - device_detach(bdev); - device_delete_child(self, bdev); - } /* during module unload there are lots of children leftover */ device_delete_children(self); diff --git a/sys/mips/mediatek/mtk_xhci.c b/sys/mips/mediatek/mtk_xhci.c index 138a4d4..55f39d5 100644 --- a/sys/mips/mediatek/mtk_xhci.c +++ b/sys/mips/mediatek/mtk_xhci.c @@ -161,14 +161,8 @@ static int mtk_xhci_fdt_detach(device_t self) { struct xhci_softc *sc = device_get_softc(self); - device_t bdev; int err; - if (sc->sc_bus.bdev) { - bdev = sc->sc_bus.bdev; - device_detach(bdev); - device_delete_child(self, bdev); - } /* during module unload there are lots of children leftover */ device_delete_children(self); |