aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2015-07-01 23:03:09 -0400
committerFelipe Balbi <balbi@ti.com>2015-07-06 13:34:08 -0400
commit43cacb03aabe62158d8e5da876054c7d48fc9963 (patch)
tree5ff1cca4d2cc79240eb078659dcd6beb9ccf07d0
parentcc1e204cb092da8495fe2c24bdc4543c259d6b34 (diff)
usb: dwc3: core: avoid NULL pointer dereference
commit 3e10a2ce98d1 ("usb: dwc3: add hsphy_interface property") introduced a possible NULL pointer dereference because dwc->hsphy_interface can be NULL. In order to fix it, all we have to do is guard strncmp() against a NULL argument. Fixes: 3e10a2ce98d1 ("usb: dwc3: add hsphy_interface property") Tested-by: Murali Karicheri <m-karicheri2@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/dwc3/core.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 5c110d8e293b..ff5773c66b84 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -446,10 +446,12 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
446 /* Select the HS PHY interface */ 446 /* Select the HS PHY interface */
447 switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) { 447 switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) {
448 case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI: 448 case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
449 if (!strncmp(dwc->hsphy_interface, "utmi", 4)) { 449 if (dwc->hsphy_interface &&
450 !strncmp(dwc->hsphy_interface, "utmi", 4)) {
450 reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI; 451 reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
451 break; 452 break;
452 } else if (!strncmp(dwc->hsphy_interface, "ulpi", 4)) { 453 } else if (dwc->hsphy_interface &&
454 !strncmp(dwc->hsphy_interface, "ulpi", 4)) {
453 reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI; 455 reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
454 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); 456 dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
455 } else { 457 } else {