From: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
To: 胡连勤 <hulianqin@vivo.com>
Cc: Michael Nazzareno Trimarchi <michael@amarulasolutions.com>,
Prashanth K <quic_prashk@quicinc.com>,
"quic_jjohnson@quicinc.com" <quic_jjohnson@quicinc.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"opensource.kernel" <opensource.kernel@vivo.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Subject: Re: 答复: [PATCH v9] usb: gadget: u_serial: Add null pointer check in gs_read_complete & gs_write_complete
Date: Tue, 3 Sep 2024 14:06:05 +0200 [thread overview]
Message-ID: <2024090346-bottling-mashing-e84e@gregkh> (raw)
In-Reply-To: <TYUPR06MB6217CE82501927931D973EDDD2932@TYUPR06MB6217.apcprd06.prod.outlook.com>
On Tue, Sep 03, 2024 at 11:58:37AM +0000, 胡连勤 wrote:
> Hello linux community expert:
>
> >> From: Lianqin Hu <hulianqin@vivo.com>
> >>
> >> Considering that in some extreme cases, when the unbind operation is
> >> being executed, gserial_disconnect has already cleared gser->ioport,
> >> triggering a gadget reconfiguration at this time and gs_read_complete
> >> gets called afterwards, which results in accessing null pointer, add a
> >> null pointer check to prevent this situation.
> >>
> >> Added a static spinlock to prevent gser->ioport from becoming null
> >> after the newly added check.
>
> >In looking at this further, shouldn't we just be moving around where we call usb_ep_disable() in gserial_disconnect()?
>
> >Can't we shut down the endpoints _BEFORE_ we set the port structures to NULL? After the endpoints are stopped, then we know that there is no outstanding i/o possible and then we can clean up properly?
>
> >Not to say that your change doesn't fix the race condition here, but cleaning up things in the proper order might be the better way as then there can not be any race conditions at all?
>
> >Have you tried that?
>
> Thank you for your guidance, we studied and tried.
I'm confused, you tried what and what happened?
greg k-h
next prev parent reply other threads:[~2024-09-03 12:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 11:54 [PATCH v9] usb: gadget: u_serial: Add null pointer check in gs_read_complete & gs_write_complete 胡连勤
2024-09-02 14:38 ` 答复: " 胡连勤
2024-09-02 16:08 ` Krzysztof Kozlowski
2024-09-03 2:23 ` 答复: " 胡连勤
2024-09-03 4:58 ` gregkh
2024-09-03 11:49 ` 答复: " 胡连勤
2024-09-03 12:05 ` gregkh
2024-09-02 16:16 ` Krzysztof Kozlowski
2024-09-03 6:26 ` gregkh
2024-09-03 11:58 ` 答复: " 胡连勤
2024-09-03 12:06 ` gregkh [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-09-05 8:05 胡连勤
2024-09-25 6:29 胡连勤
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=2024090346-bottling-mashing-e84e@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=hulianqin@vivo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=michael@amarulasolutions.com \
--cc=opensource.kernel@vivo.com \
--cc=quic_jjohnson@quicinc.com \
--cc=quic_prashk@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