Commit 448373d9 authored by Roger Quadros's avatar Roger Quadros Committed by Peter Chen

usb: cdns3: fix NULL pointer dereference on no platform data

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: 7cea9657 ("usb: cdns3: add quirk for enable runtime pm by default")
Reported-by: default avatarNishanth Menon <nm@ti.com>
Signed-off-by: default avatarRoger Quadros <rogerq@ti.com>
Acked-by: default avatarPawel Laszczak <pawell@cadence.com>
Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
parent 429ad75f
...@@ -559,7 +559,7 @@ static int cdns3_probe(struct platform_device *pdev) ...@@ -559,7 +559,7 @@ static int cdns3_probe(struct platform_device *pdev)
device_set_wakeup_capable(dev, true); device_set_wakeup_capable(dev, true);
pm_runtime_set_active(dev); pm_runtime_set_active(dev);
pm_runtime_enable(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); pm_runtime_forbid(dev);
/* /*
......
...@@ -59,7 +59,7 @@ static int __cdns3_host_init(struct cdns3 *cdns) ...@@ -59,7 +59,7 @@ static int __cdns3_host_init(struct cdns3 *cdns)
goto err1; 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; cdns->xhci_plat_data->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW;
ret = platform_device_add_data(xhci, cdns->xhci_plat_data, ret = platform_device_add_data(xhci, cdns->xhci_plat_data,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment