usb: cdns3: fix NULL pointer dereference on no platform data
authorRoger Quadros <rogerq@ti.com>
Mon, 23 Nov 2020 10:49:31 +0000 (12:49 +0200)
committerPeter Chen <peter.chen@nxp.com>
Thu, 10 Dec 2020 09:35:33 +0000 (17:35 +0800)
Some platforms (e.g. TI) will not have any platform data which will
lead to NULL pointer dereference if we don't check for NULL pdata.

Fixes: 7cea9657756b ("usb: cdns3: add quirk for enable runtime pm by default")
Reported-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Acked-by: Pawel Laszczak <pawell@cadence.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
drivers/usb/cdns3/core.c
drivers/usb/cdns3/host.c

index 54d841a..0f08aeb 100644 (file)
@@ -559,7 +559,7 @@ static int cdns3_probe(struct platform_device *pdev)
        device_set_wakeup_capable(dev, true);
        pm_runtime_set_active(dev);
        pm_runtime_enable(dev);
-       if (!(cdns->pdata->quirks & CDNS3_DEFAULT_PM_RUNTIME_ALLOW))
+       if (!(cdns->pdata && (cdns->pdata->quirks & CDNS3_DEFAULT_PM_RUNTIME_ALLOW)))
                pm_runtime_forbid(dev);
 
        /*
index 0810378..ec89f2e 100644 (file)
@@ -59,7 +59,7 @@ static int __cdns3_host_init(struct cdns3 *cdns)
                goto err1;
        }
 
-       if (cdns->pdata->quirks & CDNS3_DEFAULT_PM_RUNTIME_ALLOW)
+       if (cdns->pdata && (cdns->pdata->quirks & CDNS3_DEFAULT_PM_RUNTIME_ALLOW))
                cdns->xhci_plat_data->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW;
 
        ret = platform_device_add_data(xhci, cdns->xhci_plat_data,