]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix busdma resource leak on usb device detach.
authorIan Lepore <ian@FreeBSD.org>
Tue, 28 Sep 2021 19:29:10 +0000 (13:29 -0600)
committerIan Lepore <ian@FreeBSD.org>
Wed, 6 Oct 2021 16:08:34 +0000 (10:08 -0600)
commit6fea4b82e7b86ac680d5615f8361863353737325
treec7acdaeb59a33f860282d718cf8945579d94c1d3
parentfb49012ca448f3c7a9ae38ceaf700b8cd39be836
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)
sys/dev/usb/usb_busdma.c
sys/dev/usb/usb_busdma.h