Skip to contentSkip to conversation

usb: xhci-dwc3: Fix usage of bulk PHY API

PATCH In review Samuel Holland 3 participants 3 messages May 30, 2020 – Jun 1, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: xhci-dwc3: Fix usage of bulk PHY API

The PHY consumer is responsible for allocating the struct phy_bulk. During conversion to the bulk API, the contents of the struct were replaced by a pointer instead of the struct itself. This leads to a null pointer dereference in generic_phy_get_bulk() when setting bulk->phys.

Fixes 6dfb8a8052ee ("usb: dwc3: use the phy bulk API to get phys")
---
 drivers/usb/host/xhci-dwc3.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/host/xhci-dwc3.c +3 -3
index 563db1a426..9b22f271a7 100644
@@ -19,7 +19,7 @@
 #include <linux/usb/otg.h>
 
 struct xhci_dwc3_platdata {
-	struct phy_bulk *usb_phys;
+	struct phy_bulk usb_phys;
 };
 
 void dwc3_set_mode(struct dwc3 *dwc3_reg, u32 mode)
@@ -124,7 +124,7 @@ static int xhci_dwc3_probe(struct udevice *dev)
 	hcor = (struct xhci_hcor *)((uintptr_t)hccr +
 			HC_LENGTH(xhci_readl(&(hccr)->cr_capbase)));
 
-	ret = dwc3_setup_phy(dev, plat->usb_phys);
+	ret = dwc3_setup_phy(dev, &plat->usb_phys);
 	if (ret && (ret != -ENOTSUPP))
 		return ret;
 
@@ -167,7 +167,7 @@ static int xhci_dwc3_remove(struct udevice *dev)
 {
 	struct xhci_dwc3_platdata *plat = dev_get_platdata(dev);
 
-	dwc3_shutdown_phy(dev, plat->usb_phys);
+	dwc3_shutdown_phy(dev, &plat->usb_phys);
 
 	return xhci_deregister(dev);
 }
Signature · 1 line
2.24.1
#2 lore raw

PATCH 1/1 usb: xhci-dwc3: Fix usage of bulk PHY API

In reply to Samuel Holland

Hi Samuel,

This bug was fixed up two weeks ago,
https://patchwork.ozlabs.org/project/uboot/patch/1589435712-8795-1-git-send-email-chunfeng.yun at mediatek.com/

thanks

Quoted 42 lines · Samuel Holland

The PHY consumer is responsible for allocating the struct phy_bulk. During conversion to the bulk API, the contents of the struct were replaced by a pointer instead of the struct itself. This leads to a null pointer dereference in generic_phy_get_bulk() when setting bulk->phys.

Fixes 6dfb8a8052ee ("usb: dwc3: use the phy bulk API to get phys")
---
 drivers/usb/host/xhci-dwc3.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/host/xhci-dwc3.c +3 -3
index 563db1a426..9b22f271a7 100644
@@ -19,7 +19,7 @@
 #include <linux/usb/otg.h>
 
 struct xhci_dwc3_platdata {
-	struct phy_bulk *usb_phys;
+	struct phy_bulk usb_phys;
 };
 
 void dwc3_set_mode(struct dwc3 *dwc3_reg, u32 mode)
@@ -124,7 +124,7 @@ static int xhci_dwc3_probe(struct udevice *dev)
 	hcor = (struct xhci_hcor *)((uintptr_t)hccr +
 			HC_LENGTH(xhci_readl(&(hccr)->cr_capbase)));
 
-	ret = dwc3_setup_phy(dev, plat->usb_phys);
+	ret = dwc3_setup_phy(dev, &plat->usb_phys);
 	if (ret && (ret != -ENOTSUPP))
 		return ret;
 
@@ -167,7 +167,7 @@ static int xhci_dwc3_remove(struct udevice *dev)
 {
 	struct xhci_dwc3_platdata *plat = dev_get_platdata(dev);
 
-	dwc3_shutdown_phy(dev, plat->usb_phys);
+	dwc3_shutdown_phy(dev, &plat->usb_phys);
 
 	return xhci_deregister(dev);
 }