diff --git a/capsules/src/usb/usb_ctap.rs b/capsules/src/usb/usb_ctap.rs index 2c91c0968..ea8111069 100644 --- a/capsules/src/usb/usb_ctap.rs +++ b/capsules/src/usb/usb_ctap.rs @@ -253,18 +253,19 @@ impl<'a, 'b, C: hil::usb::UsbController<'a>> Driver for CtapUsbSyscallDriver<'a, if app.waiting { ReturnCode::EALREADY } else { + // Indicates to the driver that we have a packet to send. + let r = self + .usb_client + .transmit_packet(app.buffer.as_ref().unwrap().as_ref(), endpoint); + if r != ReturnCode::SUCCESS { + return r; + } // Indicates to the driver that we can receive any pending packet. app.waiting = true; self.usb_client.receive_packet(app); - if !app.waiting { - // The call to receive_packet() collected a pending packet. - ReturnCode::SUCCESS - } else { - // Indicates to the driver that we have a packet to send. - self.usb_client - .transmit_packet(app.buffer.as_ref().unwrap().as_ref(), endpoint) - } + ReturnCode::SUCCESS + } } else { ReturnCode::EINVAL