diff options
author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2016-10-17 10:20:38 +0000 |
---|---|---|
committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2016-10-17 10:20:38 +0000 |
commit | d3bf5efc1ff19b102b176512a66110ec84ac982d (patch) | |
tree | c35a2659be50242d73b1b0ec21d568922eca8a84 /sys/arm/at91 | |
parent | d609986008eaedae8d9e3e88f8d9c1e1c23d13a4 (diff) | |
download | src-d3bf5efc1ff19b102b176512a66110ec84ac982d.tar.gz src-d3bf5efc1ff19b102b176512a66110ec84ac982d.zip |
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
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=307518
Diffstat (limited to 'sys/arm/at91')
-rw-r--r-- | sys/arm/at91/at91_ohci.c | 6 | ||||
-rw-r--r-- | sys/arm/at91/at91_ohci_fdt.c | 6 |
2 files changed, 0 insertions, 12 deletions
diff --git a/sys/arm/at91/at91_ohci.c b/sys/arm/at91/at91_ohci.c index 3e39f5115450..4d8e30150767 100644 --- a/sys/arm/at91/at91_ohci.c +++ b/sys/arm/at91/at91_ohci.c @@ -165,14 +165,8 @@ static int ohci_atmelarm_detach(device_t dev) { struct at91_ohci_softc *sc = device_get_softc(dev); - device_t bdev; int err; - if (sc->sc_ohci.sc_bus.bdev) { - bdev = sc->sc_ohci.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/arm/at91/at91_ohci_fdt.c b/sys/arm/at91/at91_ohci_fdt.c index de3d3574deb2..51d9509fedcd 100644 --- a/sys/arm/at91/at91_ohci_fdt.c +++ b/sys/arm/at91/at91_ohci_fdt.c @@ -171,14 +171,8 @@ static int ohci_at91_fdt_detach(device_t dev) { struct at91_ohci_softc *sc = device_get_softc(dev); - device_t bdev; int err; - if (sc->sc_ohci.sc_bus.bdev) { - bdev = sc->sc_ohci.sc_bus.bdev; - device_detach(bdev); - device_delete_child(dev, bdev); - } /* during module unload there are lots of children leftover */ device_delete_children(dev); |