ARM: davinci: da8xx: fix oops in USB PHY driver due to stack allocated platform_data
authorDavid Lechner <david@lechnology.com>
Thu, 15 Mar 2018 19:17:20 +0000 (14:17 -0500)
committerSekhar Nori <nsekhar@ti.com>
Thu, 29 Mar 2018 06:48:32 +0000 (12:18 +0530)
This fixes a possible kernel oops due to using stack allocated platform
data for the USB PHY driver on DA8XX devices. If the platform device
probe is deferred, then we get a corrupt pointer for the platform data.

We now use a global static struct for the platform data so that the
platform data pointer does not get written over.

Fixes: bdec5a6b5789 ("ARM: da8xx: use platform data for CFGCHIP syscon regmap")
Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
arch/arm/mach-davinci/usb-da8xx.c

index 4d89d86ce7e580eb79f4b15ce462f44bc49efa4f..50445f0e98def51ac1e261d03746fb36ab8628fe 100644 (file)
@@ -26,6 +26,8 @@
 
 static struct clk *usb20_clk;
 
+static struct da8xx_usb_phy_platform_data da8xx_usb_phy_pdata;
+
 static struct platform_device da8xx_usb_phy = {
        .name           = "da8xx-usb-phy",
        .id             = -1,
@@ -36,15 +38,13 @@ static struct platform_device da8xx_usb_phy = {
                 * registered yet.
                 */
                .init_name      = "da8xx-usb-phy",
+               .platform_data  = &da8xx_usb_phy_pdata,
        },
 };
 
 int __init da8xx_register_usb_phy(void)
 {
-       struct da8xx_usb_phy_platform_data pdata;
-
-       pdata.cfgchip = da8xx_get_cfgchip();
-       da8xx_usb_phy.dev.platform_data = &pdata;
+       da8xx_usb_phy_pdata.cfgchip = da8xx_get_cfgchip();
 
        return platform_device_register(&da8xx_usb_phy);
 }