From: Felipe Balbi <balbi@kernel.org>
To: "Linyu Yuan (QUIC)" <quic_linyyuan@quicinc.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: [PATCH] usb: dwc3: gadget: clear gadget pointer after exit
Date: Thu, 09 Sep 2021 11:45:14 +0300 [thread overview]
Message-ID: <87bl52b0i9.fsf@kernel.org> (raw)
In-Reply-To: <DM8PR02MB8198F1672DD3A8179B5DF097E3D59@DM8PR02MB8198.namprd02.prod.outlook.com>
"Linyu Yuan (QUIC)" <quic_linyyuan@quicinc.com> writes:
>> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Sent: Thursday, September 9, 2021 3:38 PM
>> To: Linyu Yuan (QUIC) <quic_linyyuan@quicinc.com>
>> Cc: Felipe Balbi <balbi@kernel.org>; linux-usb@vger.kernel.org
>> Subject: Re: [PATCH] usb: dwc3: gadget: clear gadget pointer after exit
>>
>> On Thu, Sep 09, 2021 at 07:17:57AM +0000, Linyu Yuan (QUIC) wrote:
>> >
>> >
>> > > From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> > > Sent: Thursday, September 9, 2021 2:11 PM
>> > > To: Linyu Yuan (QUIC) <quic_linyyuan@quicinc.com>
>> > > Cc: Felipe Balbi <balbi@kernel.org>; linux-usb@vger.kernel.org
>> > > Subject: Re: [PATCH] usb: dwc3: gadget: clear gadget pointer after exit
>> > >
>> > > On Thu, Sep 09, 2021 at 01:45:47PM +0800, Linyu Yuan wrote:
>> > > > change device release function to clear gadget pointer.
>> > >
>> > > That does not properly describe what and why this change is needed.
>> > >
>> > > >
>> > > > Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
>> > > > ---
>> > > > drivers/usb/dwc3/gadget.c | 5 +++--
>> > > > 1 file changed, 3 insertions(+), 2 deletions(-)
>> > > >
>> > > > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>> > > > index 804b505..e2ab5f6 100644
>> > > > --- a/drivers/usb/dwc3/gadget.c
>> > > > +++ b/drivers/usb/dwc3/gadget.c
>> > > > @@ -4188,9 +4188,10 @@ static int dwc3_gadget_get_irq(struct dwc3
>> > > *dwc)
>> > > >
>> > > > static void dwc_gadget_release(struct device *dev)
>> > > > {
>> > > > - struct usb_gadget *gadget = container_of(dev, struct usb_gadget,
>> > > dev);
>> > > > + struct dwc3 *dwc = dev_get_platdata(dev);
>> > >
>> > > Are you sure this is the same?
>> > Yes, in dwc3_gadget_init()
>> > usb_initialize_gadget(dwc->dev, dwc->gadget, dwc_gadget_release);
>> > dev = &dwc->gadget->dev;
>> > dev->platform_data = dwc;
>> >
>> > here original code use follow container_of, it use same dev,
>> > container_of(dev, struct usb_gadget, dev);
>> > >
>> > > >
>> > > > - kfree(gadget);
>> > > > + kfree(dwc->gadget);
>> > > > + dwc->gadget = NULL;
>> > >
>> > > Why set this to NULL? Who cares about this now? What changed to
>> make
>> > > it required?
>> > It better to set to NULL for better understanding.
>>
>> Understanding of what? What issue does this fix? You need a reason to
>> make this, or any, kernel change.
>
> Sorry, let explain, for example, when do role switch, we can check it
> value to make sure it switch complete,
>
> If we do not set to NULL, it will be invalid.
Using this pointer as a role switch flag seems fragile, though.
--
balbi
next prev parent reply other threads:[~2021-09-09 8:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-09 5:45 [PATCH] usb: dwc3: gadget: clear gadget pointer after exit Linyu Yuan
2021-09-09 6:10 ` Greg Kroah-Hartman
2021-09-09 7:17 ` Linyu Yuan (QUIC)
2021-09-09 7:37 ` Greg Kroah-Hartman
2021-09-09 8:02 ` Linyu Yuan (QUIC)
2021-09-09 8:23 ` Greg Kroah-Hartman
2021-09-09 8:45 ` Felipe Balbi [this message]
2021-09-09 9:37 ` Linyu Yuan (QUIC)
2021-09-09 9:44 ` Felipe Balbi
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=87bl52b0i9.fsf@kernel.org \
--to=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=quic_linyyuan@quicinc.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).