HomeFreeBSD

Fix busdma resource leak on usb device detach.

Description

Fix busdma resource leak on usb device detach.

When a usb device is detached, usb_pc_dmamap_destroy() called
bus_dmamap_destroy() while the map was still loaded. That's harmless on x86
architectures, but on all other platforms it causes bus_dmamap_destroy() to
return EBUSY and leak away any memory resources (including bounce buffers)
associated with the mapping, as well as any allocated map structure itself.

This change introduces a new is_loaded flag to the usb_page_cache struct to
track whether a map is loaded or not. If the map is loaded,
bus_dmamap_unload() is called before bus_dmamap_destroy() to avoid leaking
away resources.

Differential Revision: https://reviews.freebsd.org/D32208

(cherry picked from commit dc91a9715f8fda4b3633388830a28a99f73cbe59)

Details

Provenance
ianAuthored on Sep 28 2021, 7:29 PM
Differential Revision
D32208: Fix busdma resource leak on usb device detach
Parents
rG4747ec0839e3: pf tests: Basic adaptive mode syncookie test
Branches
Unknown
Tags
Unknown