All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: list_del corruption (NULL pointer dereference) on xhci-pci unbind
Date: Tue, 18 Oct 2022 16:36:54 +0300	[thread overview]
Message-ID: <fc4ba1ad-3104-e538-ec63-713cda7c2984@linux.intel.com> (raw)
In-Reply-To: <Y02iOUbJd8mFNLYd@mail-itl>

On 17.10.2022 21.43, Marek Marczykowski-Górecki wrote:
> 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!

Great, thanks, I'll turn it into a proper patch.
Can I add your Reported-by and Tested-by tags to it?

> 
> 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?

Right, if bw_endpoint_list isn't empty when freeing the virt device
it means something prevented dropping the endpoint cleanly earlier.

Most likely host died or is being removed. We just want a clean exit

Thanks
-Mathias

  reply	other threads:[~2022-10-18 13:35 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
2022-10-18 13:36           ` Mathias Nyman [this message]
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=fc4ba1ad-3104-e538-ec63-713cda7c2984@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=marmarek@invisiblethingslab.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.