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

Commit 209e5fb1 authored by Tobin Ehlis's avatar Tobin Ehlis
Browse files

BnGraphicBufferProducer: Add null fence checks

Add null fence checks to BnGraphicBufferProducer::onTransact
DEQUEUE_BUFFER and GET_LAST_QUEUED_BUFFER cases. If we do find a null
fence, set to Fence::NO_FENCE and log an error.
This will avoid a crash. There still may be a synchronization issue
with NO_FENCE, but a glitch is favorable to a crash and the extra error
logging will help isolate any null fence issues going forward.

Fix: 124395884
Test: builds
Change-Id: I458aadf183e638dea04a9457cc7df5579a7e8046
parent 42f8ae92
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -781,6 +781,10 @@ status_t BnGraphicBufferProducer::onTransact(
            int result = dequeueBuffer(&buf, &fence, width, height, format, usage, &bufferAge,
                                       getTimestamps ? &frameTimestamps : nullptr);

            if (fence == nullptr) {
                ALOGE("dequeueBuffer returned a NULL fence, setting to Fence::NO_FENCE");
                fence = Fence::NO_FENCE;
            }
            reply->writeInt32(buf);
            reply->write(*fence);
            reply->writeUint64(bufferAge);
@@ -963,6 +967,10 @@ status_t BnGraphicBufferProducer::onTransact(
                ALOGE("getLastQueuedBuffer failed to write buffer: %d", result);
                return result;
            }
            if (fence == nullptr) {
                ALOGE("getLastQueuedBuffer returned a NULL fence, setting to Fence::NO_FENCE");
                fence = Fence::NO_FENCE;
            }
            result = reply->write(*fence);
            if (result != NO_ERROR) {
                ALOGE("getLastQueuedBuffer failed to write fence: %d", result);