From 2f0fe27a2bfef0b5b4621009865ed6a8bae64447 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Tue, 13 Apr 2021 20:14:16 +0000 Subject: [PATCH] audio HAL - fix UAFs Bug: 185259758 Test: N/A Change-Id: I5ec70b098a00746108e10ab39e966607d78c84ae Merged-In: I5ec70b098a00746108e10ab39e966607d78c84ae (cherry picked from commit a8ac7cf706be7a77589070ea7c62f8e1b94ce316) (cherry picked from commit 7283cbe8cbb250fc42f0358d4ca4c94f3c32b344) --- audio/core/all-versions/default/StreamIn.cpp | 8 ++++---- audio/core/all-versions/default/StreamOut.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/audio/core/all-versions/default/StreamIn.cpp b/audio/core/all-versions/default/StreamIn.cpp index f1152ca542..d38e225c0e 100644 --- a/audio/core/all-versions/default/StreamIn.cpp +++ b/audio/core/all-versions/default/StreamIn.cpp @@ -390,9 +390,9 @@ Return StreamIn::prepareForReading(uint32_t frameSize, uint32_t framesCoun } // Create and launch the thread. - auto tempReadThread = - std::make_unique(&mStopReadThread, mStream, tempCommandMQ.get(), - tempDataMQ.get(), tempStatusMQ.get(), tempElfGroup.get()); + sp tempReadThread = + new ReadThread(&mStopReadThread, mStream, tempCommandMQ.get(), tempDataMQ.get(), + tempStatusMQ.get(), tempElfGroup.get()); if (!tempReadThread->init()) { ALOGW("failed to start reader thread: %s", strerror(-status)); sendError(Result::INVALID_ARGUMENTS); @@ -408,7 +408,7 @@ Return StreamIn::prepareForReading(uint32_t frameSize, uint32_t framesCoun mCommandMQ = std::move(tempCommandMQ); mDataMQ = std::move(tempDataMQ); mStatusMQ = std::move(tempStatusMQ); - mReadThread = tempReadThread.release(); + mReadThread = tempReadThread; mEfGroup = tempElfGroup.release(); threadInfo.pid = getpid(); threadInfo.tid = mReadThread->getTid(); diff --git a/audio/core/all-versions/default/StreamOut.cpp b/audio/core/all-versions/default/StreamOut.cpp index 1519c48e12..af3307aaa5 100644 --- a/audio/core/all-versions/default/StreamOut.cpp +++ b/audio/core/all-versions/default/StreamOut.cpp @@ -376,9 +376,9 @@ Return StreamOut::prepareForWriting(uint32_t frameSize, uint32_t framesCou } // Create and launch the thread. - auto tempWriteThread = - std::make_unique(&mStopWriteThread, mStream, tempCommandMQ.get(), - tempDataMQ.get(), tempStatusMQ.get(), tempElfGroup.get()); + sp tempWriteThread = + new WriteThread(&mStopWriteThread, mStream, tempCommandMQ.get(), tempDataMQ.get(), + tempStatusMQ.get(), tempElfGroup.get()); if (!tempWriteThread->init()) { ALOGW("failed to start writer thread: %s", strerror(-status)); sendError(Result::INVALID_ARGUMENTS); @@ -394,7 +394,7 @@ Return StreamOut::prepareForWriting(uint32_t frameSize, uint32_t framesCou mCommandMQ = std::move(tempCommandMQ); mDataMQ = std::move(tempDataMQ); mStatusMQ = std::move(tempStatusMQ); - mWriteThread = tempWriteThread.release(); + mWriteThread = tempWriteThread; mEfGroup = tempElfGroup.release(); threadInfo.pid = getpid(); threadInfo.tid = mWriteThread->getTid();