usb: cdns3: fix NULL pointer dereference on no platform data
Subsystems (3)
PATCH 1/1 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.
--- drivers/usb/cdns3/core.c | 2 +- drivers/usb/cdns3/host.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/usb/cdns3/core.c +1 -1
@@ -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);/*
drivers/usb/cdns3/host.c +1 -1
@@ -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,
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Hi,
Quoted 7 lines
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 a284b7fd1b8f ("usb: cdns3: add quirk for enable runtime pm by default")Reported-by Nishanth Menon <[email protected]>Signed-off-by Roger Quadros <[email protected]>
I see the same issue on my PCI based platform.
But I afraid that there will be some conflict with applying my CDSNP series after applying this patch on Peter Chen branch :(
Quoted 23 lines
---
drivers/usb/cdns3/core.c| 2 +-drivers/usb/cdns3/host.c| 2 +-2 files changed, 2 insertions(+), 2 deletions(-)drivers/usb/cdns3/core.c +1
-1@@ -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);/* drivers/usb/cdns3/host.c +0
-0
drivers/usb/cdns3/host.c static int __cdns3_host_init(struct cdns3 *cdns) · line 65
Quoted 8 lines
drivers/usb/cdns3/host.c +1
-1@@ -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,
--
Regards,
Pawel Laszczak
Quoted 29 lines · Roger Quadros
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 a284b7fd1b8f ("usb: cdns3: add quirk for enable runtime pm by default")Reported-by Nishanth Menon <[email protected]>Signed-off-by Roger Quadros <[email protected]>--- drivers/usb/cdns3/core.c | 2 +- drivers/usb/cdns3/host.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/usb/cdns3/core.c +1
-1@@ -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);/* drivers/usb/cdns3/host.c +0
-0
drivers/usb/cdns3/host.c static int __cdns3_host_init(struct cdns3 *cdns) · line 65
Quoted 8 lines
drivers/usb/cdns3/host.c +1
-1@@ -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,
Thanks for fixing it, already applied to -next tree.
Signature · 2 lines
Thanks, Peter Chen