Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43cacb03 authored by Felipe Balbi's avatar Felipe Balbi
Browse files

usb: dwc3: core: avoid NULL pointer dereference



commit 3e10a2ce ("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: 3e10a2ce ("usb: dwc3: add hsphy_interface property")
Tested-by: default avatarMurali Karicheri <m-karicheri2@ti.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent cc1e204c
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -446,10 +446,12 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
	/* Select the HS PHY interface */
	switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) {
	case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
		if (!strncmp(dwc->hsphy_interface, "utmi", 4)) {
		if (dwc->hsphy_interface &&
				!strncmp(dwc->hsphy_interface, "utmi", 4)) {
			reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
			break;
		} else if (!strncmp(dwc->hsphy_interface, "ulpi", 4)) {
		} else if (dwc->hsphy_interface &&
				!strncmp(dwc->hsphy_interface, "ulpi", 4)) {
			reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
			dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
		} else {