Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1428580AbdDYJUf (ORCPT ); Tue, 25 Apr 2017 05:20:35 -0400 Received: from mail-eopbgr40072.outbound.protection.outlook.com ([40.107.4.72]:35184 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1428427AbdDYJU0 (ORCPT ); Tue, 25 Apr 2017 05:20:26 -0400 From: Peter Chen To: Jisheng Zhang CC: "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 Thread-Topic: [PATCH] usb: chipidea: udc: fix NULL pointer dereference if udc_start failed Thread-Index: AQHSvPgFc2dhxLAIGEWQDuspMBH/uqHVwkMAgAALqwCAAAHUAA== Date: Tue, 25 Apr 2017 09:20:20 +0000 Message-ID: References: <20170424123551.2465-1-jszhang@marvell.com> <20170425082948.GB873@b29397-desktop> <20170425171134.6a983841@xhacker> In-Reply-To: <20170425171134.6a983841@xhacker> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: marvell.com; dkim=none (message not signed) header.d=none;marvell.com; dmarc=none action=none header.from=nxp.com; x-originating-ip: [199.59.226.141] x-microsoft-exchange-diagnostics: 1;HE1PR04MB1451;7:yzBUKm/duCPQDxPFh5XdRLNqS/ZRgns+1o2rXc95d9BoovuiBDGQQ7YOlBHzvB39rs2BgMGKxF6TIbZy06NZg53lPU+8loETDWD291pxrK948rR9h4KEGB61rR8sMMHpqBCL7Hod0iNvhW+hzZOYQqDa9auXToAEs6a/pn1uZoN9S1EEWpliRsoIYnQuqS7X232YanBGaBzb8m7ZmbGET5po8/925Eq+5l/m4pMPLlb2/mc/Rc7Ltl05WIB/iYWFrYererYlwsB5q+bvIvBEyL0CxXcS9XrjHswGjQJnewLB8EWd34oJUwnXyzIHZ5ZZEfsb6Dcd3sik7I3WcPJQsw== x-ms-office365-filtering-correlation-id: 1be91790-bf21-4b10-e279-08d48bbc4b76 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081)(201702281549075);SRVR:HE1PR04MB1451; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(20161123560025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(6072148);SRVR:HE1PR04MB1451;BCL:0;PCL:0;RULEID:;SRVR:HE1PR04MB1451; x-forefront-prvs: 0288CD37D9 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39410400002)(39400400002)(39860400002)(39840400002)(39450400003)(39850400002)(102836003)(3846002)(76176999)(54356999)(50986999)(5660300001)(55016002)(74316002)(6436002)(6506006)(8936002)(77096006)(81166006)(305945005)(7736002)(6916009)(8676002)(7696004)(25786009)(2950100002)(229853002)(4326008)(6116002)(54906002)(110136004)(99286003)(9686003)(189998001)(38730400002)(53936002)(6246003)(2900100001)(33656002)(3660700001)(122556002)(3280700002)(86362001)(2906002)(66066001);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR04MB1451;H:HE1PR04MB1450.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Apr 2017 09:20:20.0626 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB1451 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v3P9KtR9030801 Content-Length: 1200 Lines: 39 >> > 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. Peter