Re: [PATCH] net: 9p: usbg: clear stale client pointer on close

Michael Grzeschik <[email protected]>
Newsgroups dev.linux.lists.v9fs,org.kernel.vger.linux-kernel,org.kernel.vger.linux-usb,org.kernel.vger.stable
Message-ID <[email protected]>
Hi

On Sat, Mar 14, 2026 at 02:16:59AM +0900, Hyungjung Joo wrote:
>p9_usbg_close() tears down the client transport, but usb9pfs keeps
>using usb9pfs->client from asynchronous TX and RX completion handlers.
>A late completion can therefore dereference a client that has already
>been freed during mount teardown.
>
>Clear usb9pfs->client under usb9pfs->lock when closing the transport,
>detach any pending TX request from in_req->context, and make the TX/RX
>completion handlers bail out once the transport has been detached. This
>keeps late completions from touching a freed or rebound p9_client.
>
>Fixes: a3be076dc174 ("net/9p/usbg: Add new usb gadget function transport")
>Cc: [email protected]
>Reviewed-by: Greg Kroah-Hartman <[email protected]>
>Signed-off-by: Hyungjung Joo <[email protected]>

I was just preparing a similar change in an series of patches. Let me
come back with a test of your patch and the comparison to my changes.

Thanks!
Michael


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEElXvEUs6VPX6mDPT8C+njFXoeLGQFAmm0UhMACgkQC+njFXoe
LGSNrQ//bivobCzCGMnkMzEuCNf9x5yt+/OvHIVGHgtlZXhMZcDYo/x6EUeXcQib
MFuI4Bh2LGLFRuWjgn0fAnBmxuIwVYcqUiLUy7d+VYLwZRStCjH0ytb4+c9kw2FY
9V5IluViM0TmW27Wk0D/48/3vhMdWAuCJTkuGKvmfLZC8IE0/YrpEivQ4VcVDpc7
2nkGveu0R8a8bcCwFUDLnzxkgUuerptpBgj5Q6m/VCbRUtSOw5AEYxHcQqCqGWLq
nyz/wruCDot1uXMobsvawXL6tL4bUgkhmgO66Zwuuf30QYP9Alq+HjdVM5uhNTk3
7D+y7g6UC1VmYU2FFrNn/66S52ZqSOKwsNiXDc487q92ONMYw86W7bVj5sBHFoS4
8nGtFwCZ16nsQYHuUQd88xFTkbf2atp8thgMGQbCkBqSAv02LS0PijPjAEw7IT9V
MaJNGhHVv33Wtqh9pZ/A9gZlq7SdCCzMau5VA6IBQW5zsIQubTOyegNZQv1zITwJ
nuLTa8gcK2ByKAX//fipf6Ac9ehHpRsqbGR3Q1vGNedtbkY54s5XKYY0JnYVHbgS
cFJEobzJfCTeEfE9DWLCs+ahQs1ia2cnsSvS3u8PaQXzufttdqWfoIUlJmjqxX/2
pLbWnGjaJbeQ4wBE7zK+AmBRP8rOF2QUGfJ4qf5Mjf1yxeFB+90=
=AlgS
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.