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

Commit c8c82388 authored by Andy Hung's avatar Andy Hung
Browse files

StreamHalAidl: Clamp return transferred value from audio HAL

Prevents crashes from audio HAL bugs.

Flag: EXEMPT bugfix
Test: adb shell test_pcm_offload -c2 -po -f1 -r48000 -T20 -E48000
Bug: 385403969
Change-Id: I186cc7a5058859eaf6466bb8b461856cb6de3c00
parent bb19e341
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -445,6 +445,10 @@ status_t StreamHalAidl::transfer(void *buffer, size_t bytes, size_t *transferred
            AUGMENT_LOG(E, "failed to read %zu bytes to data MQ", toRead);
            return NOT_ENOUGH_DATA;
        }
    } else if (*transferred > bytes) {
        ALOGW("%s: HAL module wrote %zu bytes, which exceeds requested count %zu",
                __func__, *transferred, bytes);
        *transferred = bytes;
    }
    mStreamPowerLog.log(buffer, *transferred);
    return OK;