usb: ehci-sh: fix illegal phy_init() running when platform_data is NULL
Subsystems (3)
PATCH v2 1/1 usb: ehci-sh: fix illegal phy_init() running when platform_data is NULL
If the platform_data is not set, pdata will be uninitialized value. Since the driver has the following code, if the condition is true when the pdata is uninitialized value, the driver may jump to the illegal phy_init().
if (pdata && pdata->phy_init) pdata->phy_init();
This patch also fixes the following warning:
CC drivers/usb/host/ehci-hcd.odrivers/usb/host/ehci-sh.c: In function ‘ehci_hcd_sh_probe’:drivers/usb/host/ehci-sh.c:104: warning: ‘pdata’ may be used uninitialized in this function
---
about v2:
- modify the patch description about phy_init()
drivers/usb/host/ehci-sh.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/usb/host/ehci-sh.c +1 -2
@@ -126,8 +126,7 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev) goto fail_create_hcd; } -if (pdev->dev.platform_data !=NULL ) - pdata = pdev->dev.platform_data; + pdata = pdev->dev.platform_data;/* initialize hcd */ hcd = usb_create_hcd(&ehci_sh_hc_driver, &pdev->dev,
Signature · 1 line
1.7.1
Quoted 27 lines · Yoshihiro
If the
platform_datais not set, pdata will be uninitialized value. Since the driver has the following code, if the condition is true when the pdata is uninitialized value, the driver may jump to the illegalphy_init().if (pdata && pdata->phy_init) pdata->phy_init();This patch also fixes the following warning:
CC
drivers/usb/host/ehci-hcd.odrivers/usb/host/ehci-sh.c: In function ‘ehci_hcd_sh_probe’:drivers/usb/host/ehci-sh.c:104: warning: ‘pdata’ may be used uninitialized in this functionSigned-off-by Yoshihiro Shimoda <[email protected]>---
about v2:
- modify the patch description aboutphy_init()drivers/usb/host/ehci-sh.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)drivers/usb/host/ehci-sh.c +0
-0
drivers/usb/host/ehci-sh.c static int ehci_hcd_sh_probe(struct platform_device *pdev) · line 132
Quoted 9 lines
drivers/usb/host/ehci-sh.c +1
-2@@ -126,8 +126,7 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev) goto fail_create_hcd; } -if (pdev->dev.platform_data !=NULL ) - pdata = pdev->dev.platform_data; + pdata = pdev->dev.platform_data;/* initialize hcd */ hcd = usb_create_hcd(&ehci_sh_hc_driver, &pdev->dev,