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

Commit 92bd526f authored by Phil Burk's avatar Phil Burk
Browse files

audio: use F_DUPFD_CLOEXEC to dup the MMAP buffer

Duplicate the MMAP shared memory buffer FD using F_DUPFD_CLOEXEC.
This was done to prevent clang-tidy errors.

These bugs were listed for historical reference.
Bug:  64311216
Bug: 134381208

This CL might fix this bug.
Bug: 148097400
Test: atest AAudioTests

Change-Id: I5e78109d03dc76ebaf9f82eafee3d39e5f763968
parent 780e639f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -59,7 +59,8 @@ SharedMemoryParcelable SharedMemoryParcelable::dup() const {
}

void SharedMemoryParcelable::setup(const unique_fd& fd, int32_t sizeInBytes) {
    mFd.reset(::dup(fd.get())); // store a duplicate fd
    constexpr int minFd = 3; // skip over stdout, stdin and stderr
    mFd.reset(fcntl(fd.get(), F_DUPFD_CLOEXEC, minFd)); // store a duplicate FD
    ALOGV("setup(fd = %d -> %d, size = %d) this = %p\n", fd.get(), mFd.get(), sizeInBytes, this);
    mSizeInBytes = sizeInBytes;
}