From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: Mathias Nyman <mathias.nyman@linux.intel.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: list_del corruption (NULL pointer dereference) on xhci-pci unbind
Date: Mon, 17 Oct 2022 20:43:04 +0200 [thread overview]
Message-ID: <Y02iOUbJd8mFNLYd@mail-itl> (raw)
In-Reply-To: <e56eb603-56b0-373b-b52b-c0098d669b73@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 2829 bytes --]
On Mon, Oct 17, 2022 at 07:12:36PM +0300, Mathias Nyman wrote:
> On 14.10.2022 23.29, Marek Marczykowski-Górecki wrote:
> > On Fri, Oct 14, 2022 at 07:02:13PM +0300, Mathias Nyman wrote:
> > > This whole software bandwidth issue should only be visible in Intel
> > > Panther Point PCH xHC (Ivy bridge)
> >
> > It is indeed Ivy Bridge platform.
> >
> > > Endpoints should be deleted from bw_table list, and xhci_virt_devices
> > > should be freed already before xhci_mem_cleanup() is called if all goes well.
> > >
> > > Normally endpoints are deleted from bw_table list during usb_disconnect()
> > >
> > > usb_disconnect()
> > > ...
> > > usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
> > > hcd->driver->drop_endpoint() // flags endpoint to be dropped
> > > hcd->driver->check_bandwidth()
> > > ->xhci_check_bandwidth()
> > > xhci_configure_endpoint()
> > > xhci_reserve_bandwidth() // only for Panther Point
> > > xhci_drop_ep_from_interval_table()
> > >
> > > But to avoid queuing new commands to a host in XHCI_STATE_DYING or
> > > XHCI_STATE_REMOVING state we return early, not calling xhci_reserve_bandwidth().
> >
> > Indeed when I remove that early return in xhci_check_bandwidth(), the
> > crash is gone. What's the proper solution?
> >
>
> We could probably just delete the endpoint from the bw list when freeing the device and
> endpoints. Currently we just print that "endpoint x not removed from BW list!" message
>
> does the below help?
Yes, this helps!
xhci_drop_ep_from_interval_table() does few more things, but I assume
this all doesn't matter at the xhci_free_virt_device() time, right?
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index 9e56aa28efcd..2adc0c2b470c 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -894,10 +894,12 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
> * We can't drop them anyway, because the udev might have gone
> * away by this point, and we can't tell what speed it was.
> */
> - if (!list_empty(&dev->eps[i].bw_endpoint_list))
> + if (!list_empty(&dev->eps[i].bw_endpoint_list)) {
> + list_del_init(&dev->eps[i].bw_endpoint_list);
> xhci_warn(xhci, "Slot %u endpoint %u "
> "not removed from BW list!\n",
> slot_id, i);
> + }
> }
> /* If this is a hub, free the TT(s) from the TT list */
> xhci_free_tt_info(xhci, dev, slot_id);
>
> Thanks
> -Mathias
--
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2022-10-17 18:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-31 0:31 list_del corruption (NULL pointer dereference) on xhci-pci unbind Marek Marczykowski-Górecki
2022-10-14 1:21 ` Marek Marczykowski-Górecki
2022-10-14 16:02 ` Mathias Nyman
2022-10-14 20:29 ` Marek Marczykowski-Górecki
2022-10-17 16:12 ` Mathias Nyman
2022-10-17 18:43 ` Marek Marczykowski-Górecki [this message]
2022-10-18 13:36 ` Mathias Nyman
2022-10-18 13:58 ` Marek Marczykowski-Górecki
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=Y02iOUbJd8mFNLYd@mail-itl \
--to=marmarek@invisiblethingslab.com \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.