From d110ab608ecd18ebadd4e2748597bbc7099ff20c Mon Sep 17 00:00:00 2001 From: Lephe Date: Fri, 11 Nov 2022 17:47:29 +0100 Subject: [PATCH] usb: fix freeze on sync commit for inactive pipes Performing an asynchronous commit on an inactive pipe would yield USB_COMMIT_INACTVE and *not* invoke the callback (as intended), which usb_commit_sync() ignored, causing a freeze. This issue appeared after a world switch, which (for reasons not yet known) appear to fail the first writes until a commit, and that commit would then hit an inactive pipe. --- src/usb/pipes.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/usb/pipes.c b/src/usb/pipes.c index 492646c..c6b1d6e 100644 --- a/src/usb/pipes.c +++ b/src/usb/pipes.c @@ -401,7 +401,10 @@ void usb_commit_sync(int pipe) while(rc == USB_COMMIT_BUSY); /* Wait until the commit completes */ - while(!flag) sleep(); + if(rc == 0) + { + while(!flag) sleep(); + } } /* usb_pipe_write_bemp(): Callback for the BEMP interrupt on a pipe */