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

Commit 0840cdd0 authored by Ady Abraham's avatar Ady Abraham
Browse files

RESTRICT AUTOMERGE SurfaceFlinger: fix a potential race condition in stealReceiveChannel

Add a mutex to prevent a potential race condition.

Bug: 232541124
Test: See bug for details
Change-Id: Ia338f124c786bf12d6adba10a67b9048fe9c34a5
parent 224d576c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -123,6 +123,11 @@ void EventThreadConnection::onFirstRef() {
}

status_t EventThreadConnection::stealReceiveChannel(gui::BitTube* outChannel) {
    std::scoped_lock lock(mLock);
    if (mChannel.initCheck() != NO_ERROR) {
        return NAME_NOT_FOUND;
    }

    outChannel->setReceiveFd(mChannel.moveReceiveFd());
    return NO_ERROR;
}
+2 −1
Original line number Diff line number Diff line
@@ -86,7 +86,8 @@ public:
private:
    virtual void onFirstRef();
    EventThread* const mEventThread;
    gui::BitTube mChannel;
    std::mutex mLock;
    gui::BitTube mChannel GUARDED_BY(mLock);
};

class EventThread {