Skip to content

Commit 3efb29f

Browse files
Marc Zyngiergregkh
authored andcommitted
usb: xhci: Check for xhci->interrupters being allocated in xhci_mem_clearup()
commit dcdb52d upstream. If xhci_mem_init() fails, it calls into xhci_mem_cleanup() to mop up the damage. If it fails early enough, before xhci->interrupters is allocated but after xhci->max_interrupters has been set, which happens in most (all?) cases, things get uglier, as xhci_mem_cleanup() unconditionally derefences xhci->interrupters. With prejudice. Gate the interrupt freeing loop with a check on xhci->interrupters being non-NULL. Found while debugging a DMA allocation issue that led the XHCI driver on this exact path. Fixes: c99b38c ("xhci: add support to allocate several interrupters") Cc: Mathias Nyman <[email protected]> Cc: Wesley Cheng <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Cc: [email protected] # 6.8+ Signed-off-by: Mathias Nyman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bbc66ab commit 3efb29f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/usb/host/xhci-mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
18821882

18831883
cancel_delayed_work_sync(&xhci->cmd_timer);
18841884

1885-
for (i = 0; i < xhci->max_interrupters; i++) {
1885+
for (i = 0; xhci->interrupters && i < xhci->max_interrupters; i++) {
18861886
if (xhci->interrupters[i]) {
18871887
xhci_remove_interrupter(xhci, xhci->interrupters[i]);
18881888
xhci_free_interrupter(xhci, xhci->interrupters[i]);

0 commit comments

Comments
 (0)