From patchwork Thu Mar 15 18:02:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 10285445 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A71060291 for ; Thu, 15 Mar 2018 18:03:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB2AD28BE7 for ; Thu, 15 Mar 2018 18:03:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDBEB28BE9; Thu, 15 Mar 2018 18:03:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5F48E28BE7 for ; Thu, 15 Mar 2018 18:03:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=wLOLvnjMQ2hFapBKsAJ7BrQkdjsruzwPORbZd/keaak=; b=nTX cyln9XiPIrzUquh7mFGbriEKObFhytXo+XeicBvj7sN4MRZAf89ehKnvgNi2F9pEJC/XkXOOLmS1x nan9cjtDURFlIGYcbJnKHhTYErFp7sMfQH6knKio2uL1fBGi95z3wUENA7+4Gpnrn+TXRRMz7Ppg9 e5gqqhu5Mc8SGWDzEOnXOrvDkLsg5SyZm9qZ4RJiTJ2wpA3H8ZTbK2gvTHuBuOWSOi37CJ2N9DtEA Le2ovFrdc2wgIZJj9oP6WB4iHTqxMbeK2OSIMwSzGMlht6PJHx6OhejHYnMnTsSLEC9ijoY1PSDIZ Dfqa2LZ1v65kdCb8nKKoaLn83fTM8CA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ewXDv-0003Dd-Kb; Thu, 15 Mar 2018 18:03:31 +0000 Received: from vern.gendns.com ([206.190.152.46]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ewXDf-00030D-6k for linux-arm-kernel@lists.infradead.org; Thu, 15 Mar 2018 18:03:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender: Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=97p7HepbHrSq+KDDaMu4p/yqYSWBFuR9rvTqM2GO+9c=; b=V376OptjbyzpVo/WZDW/Uy6RTs etOnKH5OE7sgtCuR0D7pZ/y4/EnMdWkCDke+uRp8sDHyN6kIikBT4ErppMrIDitD1hQOe8/Vs8m4H YRUO4YLwM9Rugrs0yuq2oSFVXxwCHd7B2jIZBW1/TVdwOM1bJ8+OxWe1dpQZtaNiMZ1CG6TtDtZHU aBTu8EmKhIAssmAnOwdPoMWYOEAJtz2OSjzd8EkCAiKhPZWsQ1gFeyOMP+csOmi+oIb8S1iSbDim3 b+HJyK9LgZLaUhp1uyOr6v2MI8hUYHdQ7QGr9eoOTcul8m4XdIztSzo/NzKk/oQ88MnK/Jjv8bnCQ qUR0QOVQ==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:38422 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1ewXBY-001ASs-Bz; Thu, 15 Mar 2018 14:01:04 -0400 From: David Lechner To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: davinci: DA8XX: fix oops in USB PHY driver due to stack allocated platform platform_data Date: Thu, 15 Mar 2018 13:02:56 -0500 Message-Id: <1521136976-32730-1-git-send-email-david@lechnology.com> X-Mailer: git-send-email 2.7.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180315_110316_018451_3B848F92 X-CRM114-Status: UNSURE ( 7.90 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bartosz Golaszewski , Sekhar Nori , David Lechner , linux-kernel@vger.kernel.org, Kevin Hilman MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Tested on OMAP-L138 LCDK board using legacy board file. Fixes: 9b504750923cb ("ARM: davinci: da8xx: Add USB PHY platform device") Signed-off-by: David Lechner --- arch/arm/mach-davinci/usb-da8xx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-davinci/usb-da8xx.c b/arch/arm/mach-davinci/usb-da8xx.c index b1e53e31..9ff9624 100644 --- a/arch/arm/mach-davinci/usb-da8xx.c +++ b/arch/arm/mach-davinci/usb-da8xx.c @@ -23,17 +23,20 @@ #define DA8XX_USB0_BASE 0x01e00000 #define DA8XX_USB1_BASE 0x01e25000 +static struct da8xx_usb_phy_platform_data da8xx_usb_phy_pdata; + static struct platform_device da8xx_usb_phy = { .name = "da8xx-usb-phy", .id = -1, + .dev = { + .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); }