Unverified Commit 37f4f983 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!9156 [OLK-6.6] USB: Fix kernel NULL pointer when unbind UHCI form vfio-pci

Merge Pull Request from: @leoliu-oc 
 
This bug is found in Zhaoxin platform, but it's a commom code bug.
Fix this by determine whether the PCI Driver of the USB controller is a
kernel native driver. If not, do not let it modify UHCI's dev->driver_data.

### Issue
https://gitee.com/openeuler/kernel/issues/I8WXZ0

### Test
Pass: Bug fix, UHCI/EHCI can be unbound/bound freely without error
 
 
Link:https://gitee.com/openeuler/kernel/pulls/9156

 

Reviewed-by: default avatarZhang Peng <zhangpeng362@huawei.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents fd9739f1 ef1cfa1f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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.
@@ -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.