libpayload/drivers/usb: Fix leaks
Don't leak buffers on device detach. Tested on qemu using: qemu-system-x86_64 -bios build/coreboot.rom -M pc -m 2048 -usb \ -device usb-ehci,id=ehci -device usb-mouse -device usb-audio,bus=usb-bus.0 \ -device usb-bt-dongle,bus=usb-bus.0 -device usb-kbd Change-Id: Ib2d80dd4590aa0dacdf2da3b614c6505c931d0be Signed-off-by: Patrick Rudolph <siro@das-labor.org> Reviewed-on: https://review.coreboot.org/23689 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
committed by
Nico Huber
parent
d5a70bdfd5
commit
1fea734e54
@@ -638,8 +638,15 @@ usb_detach_device(hci_t *controller, int devno)
|
||||
been called yet by the usb class driver */
|
||||
if (controller->devices[devno]) {
|
||||
controller->devices[devno]->destroy (controller->devices[devno]);
|
||||
|
||||
if (controller->destroy_device)
|
||||
controller->destroy_device(controller, devno);
|
||||
|
||||
free(controller->devices[devno]->descriptor);
|
||||
controller->devices[devno]->descriptor = NULL;
|
||||
free(controller->devices[devno]->configuration);
|
||||
controller->devices[devno]->configuration = NULL;
|
||||
|
||||
/* Tear down the device itself *after* destroy_device()
|
||||
* has had a chance to interoogate it. */
|
||||
free(controller->devices[devno]);
|
||||
|
Reference in New Issue
Block a user