From f2c634f8774b2de2b958326f5d9e78a27ce827bf Mon Sep 17 00:00:00 2001 From: Ryan Wendland Date: Tue, 8 Jun 2021 08:37:26 +0930 Subject: [PATCH] usb: Fix xid device removal --- lib/usb/libusbohci_xbox/xid_driver.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/usb/libusbohci_xbox/xid_driver.c b/lib/usb/libusbohci_xbox/xid_driver.c index 54173bab2..f38ec4a45 100644 --- a/lib/usb/libusbohci_xbox/xid_driver.c +++ b/lib/usb/libusbohci_xbox/xid_driver.c @@ -63,8 +63,16 @@ static xid_dev_t *alloc_xid_device(void) { } static void free_xid_device(xid_dev_t *xid_dev) { - //Find the device head in the linked list xid_dev_t *head = pxid_list; + + //If the xid is at the head of the list, remove now. + if (xid_dev == head) + { + pxid_list = head->next; + head = NULL; + } + + //Find the device head in the linked list while (head != NULL && head->next != xid_dev) { head = head->next;