From patchwork Thu Mar 15 19:17:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 10285679 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 8E7BF60386 for ; Thu, 15 Mar 2018 19:17:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8238A1FF6A for ; Thu, 15 Mar 2018 19:17:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7698428C1D; Thu, 15 Mar 2018 19:17:49 +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 040A31FF6A for ; Thu, 15 Mar 2018 19:17:49 +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=fdwzPNzpgG7x98F1dDAmNjxkWDgtJUC5BjHecHBbBtY=; b=XOj a9evH5UfKaLqCkrsg1aqPYpKnm1KRd6S8zDH9amJGDCAWGTEgrIysH8zgsvISMTXZJWzeQhaG+nz4 fIGIV7C5OVWkf03BVYFcMJL9JFNif4Zezzm7A3b1IKno5fu8PHDIUsiF6DfzqmrSDLL5EJ2VrULj/ zl386R7pOwnIjhsllMapzGcDaR8c480zWCCh/MxKomMxE+GuiIWTu6IuwI0dhH+Ajb3NZIhln4E8x B9ODU8TbdiwaRaMe4x+zW0HS4qdFJmheXY4DyqesGjAjb2eSuzIRTMhccJPJGr6xwMZ0Jhj3H8nd0 LwiUWwe35muQQLhLs5pGaDrhqfJnzWw==; 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 1ewYNi-0002BM-Ep; Thu, 15 Mar 2018 19:17:42 +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 1ewYNf-00029u-Gs for linux-arm-kernel@lists.infradead.org; Thu, 15 Mar 2018 19:17:40 +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=HBO3+nZoU0AaKMH5r0p8PdlPqjNzt8ec0qng7qWnwNU=; b=ezkBSwM7VnUQw3Q3Ogp0o6ArZi zGOEvPws3MELFxtj0WskFGnPbZgNfpAX9MEHlU9LKJ8uChL9UacJfuHav0Lkt9ZyWJ2zn7Dak1yEt m9jTMpDvEQhbtUi8jJDzatBG+J1DFBjfeebdp+cM4HyRPWLrzrGiIuMJauokZT5MEXWOhTnT2aF7v rRAvQHV8WAn6uCdFs4TajSUYsn/y9/I7pz6r4HLCzoH6pGeHiyEOcliZfDX0Mx2SfVxGL37yumRvb owmD06G/IbGnm5/6UoLKaojH7hkXN5RwtnFzSBjyX0qpvHe+3p3QKyiTuf0sNJMBXjGLDd0XQuA2v 1mqJX/vg==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:39472 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1ewYLX-001MPB-82; Thu, 15 Mar 2018 15:15:27 -0400 From: David Lechner To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] ARM: davinci: DA8XX: fix oops in USB PHY driver due to stack allocated platform platform_data Date: Thu, 15 Mar 2018 14:17:20 -0500 Message-Id: <1521141440-16418-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_121739_609580_EE9F63F1 X-CRM114-Status: UNSURE ( 8.24 ) 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. Fixes: 9b504750923cb ("ARM: davinci: da8xx: Add USB PHY platform device") Signed-off-by: David Lechner --- arch/arm/mach-davinci/usb-da8xx.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-davinci/usb-da8xx.c b/arch/arm/mach-davinci/usb-da8xx.c index 4d89d86..67d634b 100644 --- a/arch/arm/mach-davinci/usb-da8xx.c +++ b/arch/arm/mach-davinci/usb-da8xx.c @@ -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, @@ -37,14 +39,14 @@ static struct platform_device da8xx_usb_phy = { */ .init_name = "da8xx-usb-phy", }, + .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); }