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.

MFC after: 7 days
Differential Revision: https://reviews.freebsd.org/D32208

Details

Provenance
ianAuthored on Sep 28 2021, 7:29 PM
Differential Revision
D32208: Fix busdma resource leak on usb device detach
Parents
rGc83ae596f3c2: mgb: Staticize devclass and iflib structs (as is typical)
Branches
Unknown
Tags
Unknown