From d0a2bb696153f2a6e6cadd6ec177c244aac0009c Mon Sep 17 00:00:00 2001 From: Sungjoong Kang Date: Sun, 30 Sep 2012 02:31:54 -0700 Subject: [PATCH] hardware: samsung_slsi: libcamera2: Protection from re-releasing stream On releasing stream, check the existence of target stream first for protection from re-release. Bug: 7258314 Change-Id: I11f6986203f36ca4f829212b95681d6231e56c37 Signed-off-by: Sungjoong Kang --- libcamera2/ExynosCameraHWInterface2.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libcamera2/ExynosCameraHWInterface2.cpp b/libcamera2/ExynosCameraHWInterface2.cpp index cbb5a8d..246514b 100644 --- a/libcamera2/ExynosCameraHWInterface2.cpp +++ b/libcamera2/ExynosCameraHWInterface2.cpp @@ -2158,6 +2158,10 @@ int ExynosCameraHWInterface2::releaseStream(uint32_t stream_id) if (stream_id == STREAM_ID_PREVIEW) { targetStream = (StreamThread*)(m_streamThreads[0].get()); + if (!targetStream) { + ALOGW("(%s): Stream Not Exists", __FUNCTION__); + return 1; + } targetStream->m_numRegisteredStream--; ALOGV("(%s): m_numRegisteredStream = %d", __FUNCTION__, targetStream->m_numRegisteredStream); releasingScpMain = true; @@ -2173,6 +2177,10 @@ int ExynosCameraHWInterface2::releaseStream(uint32_t stream_id) } } else if (stream_id == STREAM_ID_JPEG) { targetStream = (StreamThread*)(m_streamThreads[1].get()); + if (!targetStream) { + ALOGW("(%s): Stream Not Exists", __FUNCTION__); + return 1; + } memset(&m_subStreams[stream_id], 0, sizeof(substream_parameters_t)); if (m_resizeBuf.size.s != 0) { freeCameraMemory(&m_resizeBuf, 1); @@ -2187,6 +2195,10 @@ int ExynosCameraHWInterface2::releaseStream(uint32_t stream_id) return 0; } else if (stream_id == STREAM_ID_RECORD) { targetStream = (StreamThread*)(m_streamThreads[0].get()); + if (!targetStream) { + ALOGW("(%s): Stream Not Exists", __FUNCTION__); + return 1; + } memset(&m_subStreams[stream_id], 0, sizeof(substream_parameters_t)); if (targetStream) res = targetStream->detachSubStream(stream_id); @@ -2196,6 +2208,10 @@ int ExynosCameraHWInterface2::releaseStream(uint32_t stream_id) return 0; } else if (stream_id == STREAM_ID_PRVCB) { targetStream = (StreamThread*)(m_streamThreads[0].get()); + if (!targetStream) { + ALOGW("(%s): Stream Not Exists", __FUNCTION__); + return 1; + } if (m_resizeBuf.size.s != 0) { freeCameraMemory(&m_previewCbBuf, m_subStreams[stream_id].internalPlanes); } @@ -2208,6 +2224,10 @@ int ExynosCameraHWInterface2::releaseStream(uint32_t stream_id) return 0; } else if (stream_id == STREAM_ID_ZSL) { targetStream = (StreamThread*)(m_streamThreads[1].get()); + if (!targetStream) { + ALOGW("(%s): Stream Not Exists", __FUNCTION__); + return 1; + } targetStream->m_numRegisteredStream--; ALOGV("(%s): m_numRegisteredStream = %d", __FUNCTION__, targetStream->m_numRegisteredStream); if (targetStream->m_parameters.needsIonMap) { -- 2.20.1