Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dce13716 authored by Shaju Mathew's avatar Shaju Mathew
Browse files

Zero-length packet send bug resolution for fastboot.



Bug: 208675141

Test: Treehugger, cursory test of fastbootd against macOS Monterey running fastboot.

Change-Id: Id2ac1be428470385c866d505f860e50bd9132e2e
Signed-off-by: default avatarShaju Mathew <shaju@google.com>
parent fd983825
Loading
Loading
Loading
Loading
+19 −4
Original line number Original line Diff line number Diff line
@@ -191,16 +191,30 @@ static int try_interfaces(IOUSBDeviceInterface500** dev, usb_handle* handle) {


        // Iterate over the endpoints for this interface and see if there
        // Iterate over the endpoints for this interface and see if there
        // are any that do bulk in/out.
        // are any that do bulk in/out.
        for (UInt8 endpoint = 1; endpoint <= interfaceNumEndpoints; endpoint++) {
        for (UInt8 endpoint = 1; endpoint <= interfaceNumEndpoints; ++endpoint) {
            UInt8   transferType;
            UInt8   transferType;
            UInt16  maxPacketSize;
            UInt16  endPointMaxPacketSize = 0;
            UInt8   interval;
            UInt8   interval;

            // Attempt to retrieve the 'true' packet-size from supported interface.
            kr = (*interface)
                 ->GetEndpointProperties(interface, 0, endpoint,
                                       kUSBOut,
                                       &transferType,
                                       &endPointMaxPacketSize, &interval);
            if (kr == kIOReturnSuccess && !endPointMaxPacketSize) {
                ERR("GetEndpointProperties() returned zero len packet-size");
            }

            UInt16  pipePropMaxPacketSize;
            UInt8   number;
            UInt8   number;
            UInt8   direction;
            UInt8   direction;


            // Proceed with extracting the transfer direction, so we can fill in the
            // appropriate fields (bulkIn or bulkOut).
            kr = (*interface)->GetPipeProperties(interface, endpoint,
            kr = (*interface)->GetPipeProperties(interface, endpoint,
                    &direction,
                    &direction,
                    &number, &transferType, &maxPacketSize, &interval);
                    &number, &transferType, &pipePropMaxPacketSize, &interval);


            if (kr == 0) {
            if (kr == 0) {
                if (transferType != kUSBBulk) {
                if (transferType != kUSBBulk) {
@@ -216,7 +230,8 @@ static int try_interfaces(IOUSBDeviceInterface500** dev, usb_handle* handle) {
                }
                }


                if (handle->info.ifc_protocol == 0x01) {
                if (handle->info.ifc_protocol == 0x01) {
                    handle->zero_mask = maxPacketSize - 1;
                    handle->zero_mask = (endPointMaxPacketSize == 0) ?
                        pipePropMaxPacketSize - 1 : endPointMaxPacketSize - 1;
                }
                }
            } else {
            } else {
                ERR("could not get pipe properties for endpoint %u (%08x)\n", endpoint, kr);
                ERR("could not get pipe properties for endpoint %u (%08x)\n", endpoint, kr);