linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "stern@rowland.harvard.edu" <stern@rowland.harvard.edu>
To: Peter Chen <peter.chen@nxp.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	"balbi@kernel.org" <balbi@kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	dl-linux-imx <linux-imx@nxp.com>
Subject: Re: [PATCH v2 6/6] Revert "usb: udc: allow adding and removing the same gadget device"
Date: Wed, 19 Aug 2020 10:52:36 -0400	[thread overview]
Message-ID: <20200819145236.GA181847@rowland.harvard.edu> (raw)
In-Reply-To: <20200819013014.GA16614@b29397-desktop>

On Wed, Aug 19, 2020 at 01:31:14AM +0000, Peter Chen wrote:
> On 20-08-18 10:46:55, stern@rowland.harvard.edu wrote:
> > On Tue, Aug 18, 2020 at 10:05:51AM +0000, Peter Chen wrote:
> > >  
> > > > >
> > > > > diff --git a/drivers/usb/gadget/udc/core.c
> > > > > b/drivers/usb/gadget/udc/core.c index 473e74088b1f..43351b0af569
> > > > > 100644
> > > > > --- a/drivers/usb/gadget/udc/core.c
> > > > > +++ b/drivers/usb/gadget/udc/core.c
> > > > > @@ -1386,7 +1386,6 @@ void usb_del_gadget_udc(struct usb_gadget
> > > > > *gadget)  {
> > > > >  	usb_del_gadget(gadget);
> > > > >  	usb_put_gadget(gadget);
> > > > > -	memset(&gadget->dev, 0x00, sizeof(gadget->dev));
> > > > 
> > > > Shouldn't you do this patch earlier in the series, as the
> > > > usb_put_gadget() call could have freed the memory that is being cleared here?
> > > > 
> > > 
> > > If I did it earlier, it would cause dwc3 break if people do 'git bisect', dwc3 issue is
> > > fixed at patch 5.
> > 
> > If you use the patch I posted earlier:
> > 
> > 	https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmarc.info%2F%3Fl%3Dlinux-usb%26m%3D159605415210351%26w%3D2&amp;data=02%7C01%7Cpeter.chen%40nxp.com%7C84c12532be684ba94c1708d843858e86%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637333588196922016&amp;sdata=gOe5kecj38gR9qIbkfjVkNO%2FICp0bHis30Yi2tomrc8%3D&amp;reserved=0
> > 
> > instead of this one then dwc3 would continue to work correctly during 
> > the intermediate stages of the series.
> > 
> 
> But at last, we don't want below at .release function
> 
> 	memset(dev, 0, sizeof(*dev));
> 
> It still needs another patch to delete it after dwc3 changes,
> and it changes .release function name to usb_udc_zero_release,
> this change may also not be needed.
> 
> Or I only do move memory clear operation at the first patch, and
> delete it at the last patch, it could let the reader not see
> the memory clear operation at the usb_del_gadget during the patch
> series.

One way or another, the existing code is wrong.  I guess the best we can 
do for now is to let it remain wrong during the patch series, rather 
than changing it to be wrong in a different way.

To put it another way, we already run the risk of clearing memory that 
has been freed.  The series does not make that risk any worse, and it 
eventually fixes the problem.

This means your patch should remain in its position at the end of the 
series.

Alan Stern

  reply	other threads:[~2020-08-19 14:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-10  2:25 [PATCH v2 0/6] USB: UDC: Fix memory leaks by expanding the API Peter Chen
2020-08-10  2:25 ` [PATCH v2 1/6] USB: UDC: Expand device model API interface Peter Chen
2020-08-10  2:25 ` [PATCH v2 2/6] USB: UDC: net2280: Fix memory leaks Peter Chen
2020-08-10  2:25 ` [PATCH v2 3/6] USB: UDC: net2272: " Peter Chen
2020-08-10  2:25 ` [PATCH v2 4/6] usb: cdns3: gadget: fix possible memory leak Peter Chen
2020-08-10  2:25 ` [PATCH v2 5/6] usb: dwc3: allocate gadget structure dynamically Peter Chen
2020-08-10  2:25 ` [PATCH v2 6/6] Revert "usb: udc: allow adding and removing the same gadget device" Peter Chen
2020-08-18  9:33   ` Greg KH
2020-08-18 10:05     ` Peter Chen
2020-08-18 14:46       ` stern
2020-08-19  1:31         ` Peter Chen
2020-08-19 14:52           ` stern [this message]
2020-08-20  3:40             ` Peter Chen
2020-08-20 14:25               ` stern
2020-08-18  9:33 ` [PATCH v2 0/6] USB: UDC: Fix memory leaks by expanding the API Greg KH
2020-08-18 10:07   ` Peter Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200819145236.GA181847@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.chen@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).