[Mesa-dev] [PATCH 14/14] st/omx: add workaround for bug in Bellagio

Christian König deathsimple at vodafone.de
Tue Feb 4 16:17:50 CET 2014


From: Christian König <christian.koenig at amd.com>

Not blocking for the message thread can lead to accessing freed up memory.

Signed-off-by: Christian König <christian.koenig at amd.com>
---
 src/gallium/state_trackers/omx/entrypoint.c | 13 +++++++++++++
 src/gallium/state_trackers/omx/entrypoint.h |  2 ++
 src/gallium/state_trackers/omx/vid_dec.c    |  3 +--
 src/gallium/state_trackers/omx/vid_enc.c    |  3 +--
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/gallium/state_trackers/omx/entrypoint.c b/src/gallium/state_trackers/omx/entrypoint.c
index c67b8c9..89aae41 100644
--- a/src/gallium/state_trackers/omx/entrypoint.c
+++ b/src/gallium/state_trackers/omx/entrypoint.c
@@ -103,3 +103,16 @@ void omx_put_screen(void)
    }
    pipe_mutex_unlock(omx_lock);
 }
+
+OMX_ERRORTYPE omx_workaround_Destructor(OMX_COMPONENTTYPE *comp)
+{
+   omx_base_component_PrivateType* priv = (omx_base_component_PrivateType*)comp->pComponentPrivate;
+
+   priv->state = OMX_StateInvalid;
+   tsem_up(priv->messageSem);
+
+   /* wait for thread to exit */;
+   pthread_join(priv->messageHandlerThread, NULL);
+
+   return omx_base_component_Destructor(comp);
+}
diff --git a/src/gallium/state_trackers/omx/entrypoint.h b/src/gallium/state_trackers/omx/entrypoint.h
index 41454be..af7c337 100644
--- a/src/gallium/state_trackers/omx/entrypoint.h
+++ b/src/gallium/state_trackers/omx/entrypoint.h
@@ -43,4 +43,6 @@ extern int omx_component_library_Setup(stLoaderComponentType **stComponents);
 struct vl_screen *omx_get_screen(void);
 void omx_put_screen(void);
 
+OMX_ERRORTYPE omx_workaround_Destructor(OMX_COMPONENTTYPE *comp);
+
 #endif
diff --git a/src/gallium/state_trackers/omx/vid_dec.c b/src/gallium/state_trackers/omx/vid_dec.c
index b8b519e..e2a2891 100644
--- a/src/gallium/state_trackers/omx/vid_dec.c
+++ b/src/gallium/state_trackers/omx/vid_dec.c
@@ -247,8 +247,7 @@ static OMX_ERRORTYPE vid_dec_Destructor(OMX_COMPONENTTYPE *comp)
    if (priv->screen)
       omx_put_screen();
 
-   omx_base_filter_Destructor(comp);
-   return OMX_ErrorNone;
+   return omx_workaround_Destructor(comp);
 }
 
 static OMX_ERRORTYPE vid_dec_SetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR param)
diff --git a/src/gallium/state_trackers/omx/vid_enc.c b/src/gallium/state_trackers/omx/vid_enc.c
index 3833f24..c1d8795 100644
--- a/src/gallium/state_trackers/omx/vid_enc.c
+++ b/src/gallium/state_trackers/omx/vid_enc.c
@@ -268,8 +268,7 @@ static OMX_ERRORTYPE vid_enc_Destructor(OMX_COMPONENTTYPE *comp)
    if (priv->screen)
       omx_put_screen();
 
-   omx_base_filter_Destructor(comp);
-   return OMX_ErrorNone;
+   return omx_workaround_Destructor(comp);
 }
 
 static OMX_ERRORTYPE vid_enc_SetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR param)
-- 
1.8.3.2



More information about the mesa-dev mailing list