Skip to content

Commit a54a594

Browse files
matnymangregkh
authored andcommitted
xhci: fix possible null pointer dereference at secondary interrupter removal
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]>
1 parent 9dc2924 commit a54a594

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
@@ -1861,14 +1861,14 @@ void xhci_remove_secondary_interrupter(struct usb_hcd *hcd, struct xhci_interrup
18611861
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
18621862
unsigned int intr_num;
18631863

1864+
spin_lock_irq(&xhci->lock);
1865+
18641866
/* interrupter 0 is primary interrupter, don't touch it */
1865-
if (!ir || !ir->intr_num || ir->intr_num >= xhci->max_interrupters)
1867+
if (!ir || !ir->intr_num || ir->intr_num >= xhci->max_interrupters) {
18661868
xhci_dbg(xhci, "Invalid secondary interrupter, can't remove\n");
1867-
1868-
/* fixme, should we check xhci->interrupter[intr_num] == ir */
1869-
/* fixme locking */
1870-
1871-
spin_lock_irq(&xhci->lock);
1869+
spin_unlock_irq(&xhci->lock);
1870+
return;
1871+
}
18721872

18731873
intr_num = ir->intr_num;
18741874

0 commit comments

Comments
 (0)