Skip to content

Commit fe46500

Browse files
matnymangregkh
authored andcommitted
xhci: fix possible null pointer dereference at secondary interrupter removal
commit a54a594 upstream. Don't try to remove a secondary interrupter that is known to be invalid. Also check if the interrupter is valid inside the spinlock that protects the array of interrupters. Found by smatch static checker Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/linux-usb/[email protected]/ Fixes: c99b38c ("xhci: add support to allocate several interrupters") 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 3efb29f commit fe46500

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/usb/host/xhci-mem.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,14 +1855,14 @@ void xhci_remove_secondary_interrupter(struct usb_hcd *hcd, struct xhci_interrup
18551855
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
18561856
unsigned int intr_num;
18571857

1858+
spin_lock_irq(&xhci->lock);
1859+
18581860
/* interrupter 0 is primary interrupter, don't touch it */
1859-
if (!ir || !ir->intr_num || ir->intr_num >= xhci->max_interrupters)
1861+
if (!ir || !ir->intr_num || ir->intr_num >= xhci->max_interrupters) {
18601862
xhci_dbg(xhci, "Invalid secondary interrupter, can't remove\n");
1861-
1862-
/* fixme, should we check xhci->interrupter[intr_num] == ir */
1863-
/* fixme locking */
1864-
1865-
spin_lock_irq(&xhci->lock);
1863+
spin_unlock_irq(&xhci->lock);
1864+
return;
1865+
}
18661866

18671867
intr_num = ir->intr_num;
18681868

0 commit comments

Comments
 (0)