diff mbox series

usb: cdns3: Fix issue with using incorrect PCI device function

Message ID 20230308124427.311245-1-pawell@cadence.com
State New
Headers show
Series usb: cdns3: Fix issue with using incorrect PCI device function | expand

Commit Message

Pawel Laszczak March 8, 2023, 12:44 p.m. UTC
PCI based platform can have more than two PCI functions.
USBSS PCI Glue driver during initialization should
consider only DRD/HOST/DEVICE PCI functions and
all other should be ignored. This patch adds additional
condition which causes that only DRD and HOST/DEVICE
function will be accepted.

cc: <stable@vger.kernel.org>
Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Signed-off-by: Pawel Laszczak <pawell@cadence.com>
---
 drivers/usb/cdns3/cdns3-pci-wrap.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Roger Quadros March 20, 2023, 8:10 a.m. UTC | #1
On 08/03/2023 14:44, Pawel Laszczak wrote:
> PCI based platform can have more than two PCI functions.
> USBSS PCI Glue driver during initialization should
> consider only DRD/HOST/DEVICE PCI functions and
> all other should be ignored. This patch adds additional
> condition which causes that only DRD and HOST/DEVICE
> function will be accepted.
> 
> cc: <stable@vger.kernel.org>
> Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>

Reviewed-by: Roger Quadros <rogerq@kernel.org>
diff mbox series

Patch

diff --git a/drivers/usb/cdns3/cdns3-pci-wrap.c b/drivers/usb/cdns3/cdns3-pci-wrap.c
index deeea618ba33..1f6320d98a76 100644
--- a/drivers/usb/cdns3/cdns3-pci-wrap.c
+++ b/drivers/usb/cdns3/cdns3-pci-wrap.c
@@ -60,6 +60,11 @@  static struct pci_dev *cdns3_get_second_fun(struct pci_dev *pdev)
 			return NULL;
 	}
 
+	if (func->devfn != PCI_DEV_FN_HOST_DEVICE &&
+	    func->devfn != PCI_DEV_FN_OTG) {
+		return NULL;
+	}
+
 	return func;
 }