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

Commit e32a1d7c authored by Mengjie Xie's avatar Mengjie Xie Committed by Wonsik Kim
Browse files

mTraits is used without been locked

mTraits could be read/written by more than one thread,
And it will cause some timing issue if there is no synchronization
Solution:
use getId() instead of mTraits->id when use its id.

Bug: 142629712
Test: This is seldom timing issue, and may be reproduced by monkey test (enable uasan)
Merged-In: I96870027fd171fea15957b292c4898043262d9cf
Change-Id: I96870027fd171fea15957b292c4898043262d9cf
(cherry picked from commit 51f5abaf)
parent 671c76ff
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -600,7 +600,7 @@ c2_status_t C2AllocatorIon::newLinearAllocation(
    }

    std::shared_ptr<C2AllocationIon> alloc
        = std::make_shared<C2AllocationIon>(dup(mIonFd), capacity, align, heapMask, flags, mTraits->id);
        = std::make_shared<C2AllocationIon>(dup(mIonFd), capacity, align, heapMask, flags, getId());
    ret = alloc->status();
    if (ret == C2_OK) {
        *allocation = alloc;
@@ -622,7 +622,7 @@ c2_status_t C2AllocatorIon::priorLinearAllocation(
    // TODO: get capacity and validate it
    const C2HandleIon *h = static_cast<const C2HandleIon*>(handle);
    std::shared_ptr<C2AllocationIon> alloc
        = std::make_shared<C2AllocationIon>(dup(mIonFd), h->size(), h->bufferFd(), mTraits->id);
        = std::make_shared<C2AllocationIon>(dup(mIonFd), h->size(), h->bufferFd(), getId());
    c2_status_t ret = alloc->status();
    if (ret == C2_OK) {
        *allocation = alloc;