Skip to content

Commit 349b11e

Browse files
committed
xhci: Fix null pointer dereference in remove if xHC has only one roothub
jira VULN-69751 cve CVE-2022-49962 commit-author Mathias Nyman <mathias.nyman@linux.intel.com> commit 4a593a6 The remove path in xhci platform driver tries to remove and put both main and shared hcds even if only a main hcd exists (one roothub) This causes a null pointer dereference in reboot for those controllers. Check that the shared_hcd exists before trying to remove it. Fixes: e0fe986 ("usb: host: xhci-plat: prepare operation w/o shared hcd") Reported-by: Alexey Sheplyakov <asheplyakov@basealt.ru> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20220825150840.132216-2-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 4a593a6) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 9fe8a2b commit 349b11e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/usb/host/xhci-plat.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,17 @@ static int xhci_plat_remove(struct platform_device *dev)
405405
pm_runtime_get_sync(&dev->dev);
406406
xhci->xhc_state |= XHCI_STATE_REMOVING;
407407

408-
usb_remove_hcd(shared_hcd);
409-
xhci->shared_hcd = NULL;
408+
if (shared_hcd) {
409+
usb_remove_hcd(shared_hcd);
410+
xhci->shared_hcd = NULL;
411+
}
412+
410413
usb_phy_shutdown(hcd->usb_phy);
411414

412415
usb_remove_hcd(hcd);
413-
usb_put_hcd(shared_hcd);
416+
417+
if (shared_hcd)
418+
usb_put_hcd(shared_hcd);
414419

415420
clk_disable_unprepare(clk);
416421
clk_disable_unprepare(reg_clk);

0 commit comments

Comments
 (0)