Skip to contentSkip to conversation

xhci: fix memory leak regression when freeing xhci vdev devices depth first

PATCH Applied Justin Chen 2 participants 2 messages Jun 24 – Jun 25

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xhci: fix memory leak regression when freeing xhci vdev devices depth first

From: Mathias Nyman <[email protected]>

commit edcbe06453ddfde21f6aa763f7cab655f26133cc upstream

Suspend-resume cycle test revealed a memory leak in 6.17-rc3

Turns out the slot_id race fix changes accidentally ends up calling xhci_free_virt_device() with an incorrect vdev parameter. The vdev variable was reused for temporary purposes right before calling xhci_free_virt_device().

Fix this by passing the correct vdev parameter.

The slot_id race fix that caused this regression was targeted for stable, so this needs to be applied there as well.

---
 drivers/usb/host/xhci-mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-mem.c +1 -1
index fb81e61a599d..7f75298a09d6 100644
@@ -961,7 +961,7 @@ static void xhci_free_virt_devices_depth_first(struct xhci_hcd *xhci, int slot_i
 out:
 	/* we are now at a leaf device */
 	xhci_debugfs_remove_slot(xhci, slot_id);
-	xhci_free_virt_device(xhci, vdev, slot_id);
+	xhci_free_virt_device(xhci, xhci->devs[slot_id], slot_id);
 }
 
 int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 5 lines

xhci: fix memory leak regression when freeing xhci vdev devices depth first

Pass xhci->devs[slot_id] instead of the reused vdev temporary to xhci_free_virt_device() in the leaf path of xhci_free_virt_devices_depth_first().

Queued for 5.15, thanks!

--
Thanks,
Sasha