A failed transfer of the boot acknowledgment must not start the image
or leave a boot callback attached to subsequent responses. Keep the
session usable so the host can retry the command.

Fixes: 3aab70afc531 ("usb/gadget: add the fastboot gadget")
Signed-off-by: Carlo Caione <[email protected]>
---
 drivers/usb/gadget/f_fastboot.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 9a2e9850112..68fe657f891 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -492,6 +492,11 @@ static void do_exit_on_complete(struct usb_ep *ep, struct 
usb_request *req)
 #ifndef CONFIG_XPL_BUILD
 static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
 {
+       req->complete = fastboot_complete;
+       /* Do not boot if the acknowledgment transfer failed. */
+       if (req->status)
+               return;
+
        fastboot_boot();
        do_exit_on_complete(ep, req);
 }

-- 
2.56.0

Reply via email to