mm-video-v4l2: venc: Protect buffer from being freed while accessing am: a569853311 am: 2fcd17bd3a am: 95656fe660 am: fab48ae9b1 am: 238577213a am: f349f65cac

am: 79202f8342

Change-Id: Iec1e4dd02edeaa5ec9e9331ec19b6d3929a7faa1
This commit is contained in:
Santhosh Behara 2017-10-10 21:55:37 +00:00 committed by android-build-merger
commit 6523f2597d

View file

@ -2671,6 +2671,7 @@ OMX_ERRORTYPE omx_video::use_output_buffer(
return OMX_ErrorBadParameter; return OMX_ErrorBadParameter;
} }
auto_lock l(m_buf_lock);
if (!m_out_mem_ptr) { if (!m_out_mem_ptr) {
output_use_buffer = true; output_use_buffer = true;
int nBufHdrSize = 0; int nBufHdrSize = 0;
@ -3615,6 +3616,7 @@ OMX_ERRORTYPE omx_video::free_buffer(OMX_IN OMX_HANDLETYPE hComp,
nPortIndex, (unsigned int)m_sOutPortDef.nBufferCountActual); nPortIndex, (unsigned int)m_sOutPortDef.nBufferCountActual);
if (nPortIndex < m_sOutPortDef.nBufferCountActual && if (nPortIndex < m_sOutPortDef.nBufferCountActual &&
BITMASK_PRESENT(&m_out_bm_count, nPortIndex)) { BITMASK_PRESENT(&m_out_bm_count, nPortIndex)) {
auto_lock l(m_buf_lock);
// Clear the bit associated with it. // Clear the bit associated with it.
BITMASK_CLEAR(&m_out_bm_count,nPortIndex); BITMASK_CLEAR(&m_out_bm_count,nPortIndex);
m_sOutPortDef.bPopulated = OMX_FALSE; m_sOutPortDef.bPopulated = OMX_FALSE;