Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1949077AbdDYPYB (ORCPT ); Tue, 25 Apr 2017 11:24:01 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:55332 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1949140AbdDYPXh (ORCPT ); Tue, 25 Apr 2017 11:23:37 -0400 Subject: Re: [PATCH] usb: chipidea: udc: fix NULL pointer dereference if udc_start failed To: Peter Chen , Jisheng Zhang References: <20170424123551.2465-1-jszhang@marvell.com> <20170425082948.GB873@b29397-desktop> <20170425171134.6a983841@xhacker> Cc: "gregkh@linuxfoundation.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" From: Stefan Wahren Message-ID: <0ac4bc53-dd26-0b90-c84e-a94d01a6d5e4@i2se.com> Date: Tue, 25 Apr 2017 17:21:59 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:QZOC34w5cyZaPAxKzGJolqKS77uHey6MOD+LBL38Q/8xVfLc/HQ HTsIl/N8GT7twzQ1BJ6S+tvPZpwhoWZe7ZyNtVYGLdM5jYkwQtY2WNpoq0Ecxlt0FSDKiY5 rFpUzuSVh3mk80bQorA84nz259+1MsM/sXzuhZC3z//IYZKFuw4qMmjNfhSS8upM9CwtmqT x5WWtF+YbI3l5+KqTIUYw== X-UI-Out-Filterresults: notjunk:1;V01:K0:O2xUJde6vok=:kXymuTUhFck1WWD//nIY8W +iBmFUeUw1Bm7HmqhiXc/8dv6UYy0F9H6uOxYAbHhFOvksBYe1eElTnFozrF5uZBfIvpxPyyf mQrnx0mY7tUEip4R3vodYKksTxInFU81xjPpxZ2VTGXzmpV/EeUPA8HZBplnz2k4TBMXXnd4i AIdRkUIm20wS3mVUgIDUATfkUPXotmNUPpZ4aY6RlIUjU3+J84B8KDZmKl48agSrGSUUekgqt Gjk1I6Bg1om+D5mUh+NB2TofWN++CGubmIX3W1BT6OWNVG8rG+r6mTQGge/gdzc2oRG1roHDo 0NhZtFTTzIU6bw+sPwr7SewkfcMwQyMwarAJTICZbTpD7gzvRhb25aCsq5jdnI/0wxBs8fIiw j6xwoIBP0yrhWX5ygclQrunDew38NqovHMgczS4hBafDhUAqLJgd6Y0/fBOCNdUd8fBFtCuqj edOi5Y6KyXIuUMokiyIKbvqd2D+pPjiHBmq7n2Th1THXXdXvlrvQvg7bXRlVFCIncSTPkYPFC WNk+37hdCtGtIR52YKm+d1OxZ+h0P+sNHhkhkdQAZqpFJxgwQIE3jY6MG9PqD+CK17pIxlwZj pv8awyTCB+AZv41OVsE79oSfjU+8eJqrpd4Y3zdK9KEQiE5EjB4dUVxSpe/dQ0BRsqVR3CcNb /+N+FC1aCRx5PR/BLBLqCpKej96NfzjTIgx/2X6qHqi0+i0vwavLjXAcL4M5VLkDB9UoLfijv 37prDquGNJUvUQTE Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1538 Lines: 48 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. Shouldn't make a Fixes tag sense at least? > > Peter > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel