[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2024090346-bottling-mashing-e84e@gregkh>
Date: Tue, 3 Sep 2024 14:06:05 +0200
From: "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
To: 胡连勤 <hulianqin@...o.com>
Cc: Michael Nazzareno Trimarchi <michael@...rulasolutions.com>,
Prashanth K <quic_prashk@...cinc.com>,
"quic_jjohnson@...cinc.com" <quic_jjohnson@...cinc.com>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"opensource.kernel" <opensource.kernel@...o.com>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>
Subject: Re: 答复: [PATCH v9] usb: gadget: u_serial: Add null pointer check
in gs_read_complete & gs_write_complete
On Tue, Sep 03, 2024 at 11:58:37AM +0000, 胡连勤 wrote:
> Hello linux community expert:
>
> >> From: Lianqin Hu <hulianqin@...o.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
Powered by blists - more mailing lists