Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2997011AbdDZJZJ (ORCPT ); Wed, 26 Apr 2017 05:25:09 -0400 Received: from mail-bn3nam01on0050.outbound.protection.outlook.com ([104.47.33.50]:9120 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S968314AbdDZJFQ (ORCPT ); Wed, 26 Apr 2017 05:05:16 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=fail action=none header.from=nxp.com; Date: Wed, 26 Apr 2017 17:05:02 +0800 From: Peter Chen To: Jisheng Zhang CC: Stefan Wahren , "gregkh@linuxfoundation.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH] usb: chipidea: udc: fix NULL pointer dereference if udc_start failed Message-ID: <20170426090502.GB4375@b29397-desktop> References: <20170424123551.2465-1-jszhang@marvell.com> <20170425082948.GB873@b29397-desktop> <20170425171134.6a983841@xhacker> <0ac4bc53-dd26-0b90-c84e-a94d01a6d5e4@i2se.com> <20170426162526.7c8ef827@xhacker> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20170426162526.7c8ef827@xhacker> User-Agent: Mutt/1.5.24 (2015-08-30) X-EOPAttributedMessage: 0 X-Matching-Connectors: 131376711134908612;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39380400002)(39410400002)(39400400002)(39850400002)(39450400003)(39840400002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(199003)(24454002)(189002)(9170700003)(50466002)(4326008)(8936002)(8676002)(106466001)(47776003)(81166006)(46406003)(38730400002)(105606002)(23726003)(110136004)(356003)(83506001)(104016004)(85426001)(2906002)(50986999)(54356999)(54906002)(93886004)(55016002)(305945005)(86362001)(33716001)(77096006)(6246003)(189998001)(53936002)(229853002)(4001350100001)(97756001)(33656002)(2950100002)(6916009)(76176999)(1076002)(9686003)(5660300001)(6666003)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM2PR0301MB1197;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;A:1;MX:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD021;1:K2z+WHP2POUe5RtCHV9iGIjnZn8QIAiGJG8G0274bW18l7MHH1bUwFrIl3DTIkZRfqLj9yYiMfSilRZW2jV+2muzVGg1APoVyb7VOkkvf7HrTXLJgElEunZLyVE2LFTssSow9T+83ikAB31aMX2Hrp1ABtEQjiPhjjOhHUGri9mzffMl24ZJdtWulOH3mxlc8xb8mSkcmeFH0I5Hhum7PuzNyJfOBtQRDopmJgmNaO0Eb4hdeizLyLWmCyW/b1E7sBtoHGuCdJqUZCYrNyQh3mB+rkwpfFqAItOUZ9Rb5PJ9ycDec4lhHhC6Enqp7rlcjAd5JJXOnD+W/TFn9u2eknEJDlo7Z24XpL7UK8T4J/LH7ALGeb9L44YVe7mZiSrjNeQQUN1sJtgT7wIn31RN0LN27tpd5nFeCFhmDLCC0EaaV9SA5qNzRRaE+TLuTOz15WmQHwkN6WSaMyB5bWTmb6YVf3EzKa+XsXkXfPv+cx8B4wsQioSxFGSAs/AFuTFiUnBDOfsgDJHvsT0s8uPVVU608OKWEdd3pm66qIaABvOXQuUFqqqlN8fd6bAZtDgxuKcbSIVx4ZwW7uppH7a8AfGHWEm3/d7OsVonZKM6kOnhHo3nkntWXZRxAgY/g+fe X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3c035db0-43ae-4c68-245b-08d48c835956 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131430075)(201703131517081);SRVR:DM2PR0301MB1197; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1197;3:1wyCwP+9S21YRYQun7wGLYPy/Ahyoc+MglxBzLSYkya1+ivEqhA7ysAcLsBHFBxaXXhnlWfeBSVUQwvJZaa2HhNDSQ42MvfZtLBYzBnN90/PM9qTKl6W6GQGOVPvkZwQm9zBPCWLAgnirEogU/9Q3I0+KUm+gByGV0LHiTlS8wlIeG+ed2RHuWoov6hynOrrOCey6X/QbKX8NRwYsUMqIRz9QZ2T/0+hQgbyrTSZXJFDeR8cA94U3JW9Tcq4yDFzy8RH86P7KbLJlvUEOFYts7lP51qvIsR4wIwBsEySDW7ISYofb2EuPeie39olGftnADEbUTDaWNvkRR9bVRK+N7lS1dr1iJafoTMWcRlkZwWQSlni+Tqf5c7HrudLnzobcm9vF+19EbcdoZq1h4V4aOCV17bgECTuvDNbtikdUn8tXuqLH2NcAlNP57M+jXmc;25:dS8VLNxFZa2s1Jnxau2S2AcPoEfK5Qi+8FB4o+8rao8WrYAPJmUD871SnotRj6Jj0dXJF1eTM+0CBo7o/FE53CHt1tH7R7EUU5FMKb8grC2X+vfPu7DjEMcKgX9wp3k9YnvGT8e7kNm5mFIZvlbztrt/TaAynmjQ2u0stUdOnn49XKzZnKFDLttKOpVjJXOpiOVk7iNnePIWKCal8r6A5bfQGbZDCkv6+b/01RRegnVU5XPPggVNzmgJRl86zCKcATM9ERH2kF44AjBUD2czcUgjiPa+zxF8bMQJsjjabZewYxcvBJuY0jbRVwLD+Cqy7uCPN70MVEuaUuyqiZRF0YewCqwnNDHySOh2xHh3d0JS3jeXpfMWdpsEQWWlsWiFFFitg6JC7y8RQVyiySYDZ35g8iNpanOgdiWnji7VnbbMeGgzb+2/mdTB8MwmPUhCsX9/zvLbFwqO6dZH5W6oNw== X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1197;31:0M+fhFr3ljxSFBWe2uEXRuZznDpFy9lRFmzmJQl+8Du8Jn68+GwoQ5R5qbHPI5gE4H1+mqhdK4VUBUk2BqKbQ5l0Sjxu+lb9f4OY2vFdWTXH7+Tob/+bSZHWt5O62WuHXZGA5Uhn71E8z3fXcjMSwhfSNHJX4KjOmu5M2wOV7LQ3w4HuJ4RtXM/mptWFIwHZYRxtJ56MIF8A56cu4qrlUgzUeZETCDacLUc0Ky0qf4kbzSvX9x4dGY7gBu8oXwG0YCLQoP+uG7KFEyUPXz9EK+XqPZlza2rsrbZdxw1FoZ8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(601004)(2401047)(13015025)(8121501046)(5005006)(13017025)(13023025)(13018025)(13024025)(93006095)(93001095)(10201501046)(3002001)(6055026)(6096035)(20161123556025)(20161123563025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123561025)(20161123565025);SRVR:DM2PR0301MB1197;BCL:0;PCL:0;RULEID:(400006);SRVR:DM2PR0301MB1197; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1197;4:qdyPht2U3BUcDBLIA+TsY8SS2Wsj6K6oIX6LLhsicPt5BgmaykDDx4bmMSwy/PdWSLQILVPL3ipjvwL5LKnXOeGpfP1XUq6MGp7uFJzSpAYj1DFwS0I5sDaD7t1l339x+dFV0uVbjPqDV2/mUEFBPL3EQqG5BzJZ38d8f/Ld6sAkbgsU4b5YG2qfZbr4uQl2ZJruLn/tnP01llNxHHU19dzri5klSrDq3eUqgweZ2CCMOrWL/ouRo2ApwOrUOl5koEfyZqSzRq8mpTOQjV9JJYa8lvqmFK54yp7FUE0jk6o8i12LksRliKB3bKdrXYzB8GSe2xGN77ZAIhEU1GTrXS5nJZwQ9Rhfbe1sA26RoGqMZIe6NCx/BaUZbHc1UEa6/oiH8F9LQxnKo8HGQrVY2svzWQaY67573zizHjYSCMy6hr054Awgmu/OyhKDDRfji+1PpZsCFz2FPpBPFI1ihybsJonVT1j/Yi2dJy4j7OBSP3FXgiOgHHnRUlaEX1MwcNMrD5gnCqVLP3tK28nEzg/ECzMCV3/rm5CxsQ11I2sbLPI4JYBZz15e9jI18If2RMRdUXYvlYiCZybTFNtuzJ5lIzFKEOlZQkB9EnkhIt06rWomWFnmmEfkcYfoXlm3KLgO3/YgWt7pRvV4r55bypuumYLzbP4t0cXZN9B6yuNIY0RSA4hScqwSQefGkUzFRWAz0UY23CWLp4en0UqnQyvCC1UACN/reDvufzU1Coz3BT9EOktr1Njy2AZmS21IzZy2AlLYBpGo+AnSsoZgSCLuLpUg3Cwj6geEkNy7d5360FvevTfeWIPDhM/GOL1x9dVAr2z1mCxXYxTqp5Yv8f4+Ry03iLkMCZTCtxFYt71qnQXguy05qGZmo58h9o8T X-Forefront-PRVS: 0289B6431E X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM2PR0301MB1197;23:XCbnjToQ/FF8HPVihtEbg5830dYWpCs+OlF3isS?= =?us-ascii?Q?C7FphdRhimukI1+Jvb7Nu0qlAqNOfJOsfwfFnbcMxHvqplXKL0ZhhHbetwQ1?= =?us-ascii?Q?zAqqOG+qStUjbIwnZuvl/gvLiG1tSKGRfaWwVERKbyn+6CSJUefIMG3WikEf?= =?us-ascii?Q?SawnB3eHkRjt4BPRT0eB04WIrJdX+hOwhoeF0/gukwacdYKEqxCsUS5J/w3a?= =?us-ascii?Q?RC1by1f8tgpZqAJJSPmuOYmu23Aoj8+2/5Rkdmut1jjEkwfWA/de8DzFwXp+?= =?us-ascii?Q?YV1MVBVNHS+EET6iayM1Eh7BxcvvBrk4dmzWmTVpWmFEY9K+HfXNY6iKjuGK?= =?us-ascii?Q?1RZcHk/py40fMIpq596A6zBMHnZACpQm3xsBMIqLyPUK0yxoIpOS9jY3x5f4?= =?us-ascii?Q?dvGJeWHcj3cviHpnG8ZXMfRjK3nqubIGRHpugOdW61u6D+DuzwiBPTKLPYwz?= =?us-ascii?Q?nGGjL0p00sOTRemzNhEEW8RnpPhPGu7sk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ascii?Q?27GVaeEhSHlOCpFo38AfJBqla+v+qJGKrVIz3MTP1Cf1xmmGkxQD+PhIzWu0?= =?us-ascii?Q?C5qgBV0V1Xg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1197;6:IEnfQqlIePMW9UdW7llWo8iRTjNF2cMAExa9X1WZ1xNjccKg1R6J3eKmzx0m5szoJi1daBOl6bd2HQRSFpRzY/bhVmRx1PRXhPYokwOf76KCbMaQ6PbuuXqcMOVJMSblREnfRaoMmj9SZx4x4bF/kEfsjkMuktQWxQ60k+xZ+bFji6RnpknYYASLiufe6EmuAVi+Pw02OS0AJJh/0yL2toK0LAzQ6JAE895YhZV3RiHuak/FSNG/hWTd6WFAdGOW3krek9H7SZORDsCdGM39mly/oFUVrXpke5NIB/aAWJsIkLRYsX97Vii2u6W9GBiUVlNdUS2bANR798D9f+MzSmhkZx/c8ialwjkv/k5bXD9W+GBChMdAs5zBAFRW15L/SS6ODPC0+JXWhhHV1L9HLpWkYzQ70F4A+Joz8bmQghyv+igzp6h19bGlEW/7HBBU8npt70D2ogtdZVSlxZXSI46oKGLKedWLZylmB8kirnzbIRHQvDcxB2sDYQa/FcfpzPpJAJ9ncx8zL0plgwdO2A==;5:fHY9uG0b7/nIz+s5DRHWde6fppf1hLeaCyFYVRMxcY3PR1Bf3gGBUhdEZhfJSxgoWp7fHCGlpY+u1QWC2UNpaqy9pk9HEQkPwownUBq+tdBjhqTJDi3sSzkO/oQaCfwugC5JXjHrTrQjtMVg5EYU18AGL1NwDLSc/dZUrnCg5vtWj+anSdI4ul342Q6FWnBl;24:SOe60v5btx6YZNeQuNGRh3BpeY2OznN+tONKZ8Jdn56jzRD+KX+k9creSnUchZsaqeUzu3nb34WO/0D1OZ5sRHDoYT9KGS0Yr1XNzBLznWc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB1197;7:YoiBqojpqf6PzkxWuYxMUNKEB5S1Xrl41tMvlJvsRw6DnrN/NLbZ2VzHH7mL6J+3DAz+DnfRMeaSM/L/3ZSpdJHHQB+qqgO7vEhM065g0Pi9MexOTM+sdBw19iQ4S0pXfIuvpSKb0CKWA1ep4+ORaLigIZ71pZLydQx3Jat55kjKZCvwLrr9hmTlNBztnwmb5/Ca3r+7JrHiDuxUvC3hnUAghsJ2nZtyzu5/IIIFX/ElhfOmp4F/cxWtoqmuNH6iCLqOCGMm0EoFsCPdE46w7ijxvo5S/CgXKwDt6PNfrs5jCBDE000V5RFM5nW6hWgcnxaXESrTTLH7If+wOj173A== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2017 09:05:13.1164 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB1197 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2054 Lines: 60 On Wed, Apr 26, 2017 at 04:25:26PM +0800, Jisheng Zhang wrote: > On Tue, 25 Apr 2017 17:21:59 +0200 > Stefan Wahren wrote: > > > Am 25.04.2017 um 11:20 schrieb Peter Chen: > > > > > >>>> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c > > >>>> index f88e9157fad0..60a786c87c06 100644 > > >>>> --- a/drivers/usb/chipidea/udc.c > > >>>> +++ b/drivers/usb/chipidea/udc.c > > >>>> @@ -1984,6 +1984,7 @@ static void udc_id_switch_for_host(struct > > >>>> ci_hdrc *ci) int ci_hdrc_gadget_init(struct ci_hdrc *ci) { > > >>>> struct ci_role_driver *rdrv; > > >>>> + int ret; > > >>>> > > >>>> if (!hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DC)) > > >>>> return -ENXIO; > > >>>> @@ -1996,7 +1997,10 @@ int ci_hdrc_gadget_init(struct ci_hdrc *ci) > > >>>> rdrv->stop = udc_id_switch_for_host; > > >>>> rdrv->irq = udc_irq; > > >>>> rdrv->name = "gadget"; > > >>>> - ci->roles[CI_ROLE_GADGET] = rdrv; > > >>>> > > >>>> - return udc_start(ci); > > >>>> + ret = udc_start(ci); > > >>>> + if (!ret) > > >>>> + ci->roles[CI_ROLE_GADGET] = rdrv; > > >>>> + > > >>>> + return ret; > > >>>> } > > >>>> -- > > >>> Thanks for fixing it. In fact, we'd better return failure if ret && > > >>> ret != -ENXIO at probe, it stands for initialization for host or > > >>> gadget has failed. > > >>> > > >> I got your meaning. I'll cook v2. I don't have preference, since either one can fix the > > >> issue. > > >> > > > Both are needed, you don't need to send this one again. Only a new one, thanks. > > > > I'm not sure how easy it is to reproduce the issue. > > It's easy to reproduce it (100%) on arm64 platforms after commit > 1dccb598df549 ("arm64: simplify dma_get_ops"). This commit could > make all dma related operations failed, then udc_start() would fail > with -ENOMEM. > > On other platforms, it's not easy. > > > > > Shouldn't make a Fixes tag sense at least? > > maybe 3f124d233e97 ("usb: chipidea: add role init and destroy APIs" I will cc stable, thanks. -- Best Regards, Peter Chen