Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[linux-6.6.y] USB:Fix kernel NULL pointer when unbind UHCI form vfio-pci #260

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions drivers/usb/core/hcd-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static void for_each_companion(struct pci_dev *pdev, struct usb_hcd *hcd,
struct pci_dev *companion;
struct usb_hcd *companion_hcd;
unsigned int slot = PCI_SLOT(pdev->devfn);
struct pci_driver *drv;

/*
* Iterate through other PCI functions in the same slot.
Expand All @@ -60,6 +61,13 @@ static void for_each_companion(struct pci_dev *pdev, struct usb_hcd *hcd,
PCI_SLOT(companion->devfn) != slot)
continue;

drv = companion->driver;
if (drv &&
strncmp(drv->name, "uhci_hcd", sizeof("uhci_hcd") - 1) &&
strncmp(drv->name, "ohci-pci", sizeof("ohci-pci") - 1) &&
strncmp(drv->name, "ehci-pci", sizeof("ehci-pci") - 1))
continue;

/*
* Companion device should be either UHCI,OHCI or EHCI host
* controller, otherwise skip.
Expand Down
Loading