From 959c2d1edbf56934f6d313a48136f6f1740dc549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Tue, 10 Nov 2020 15:52:00 +0200 Subject: [PATCH] egl/dri2: fix race between image create and egl_image_target_texture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All other functions calling _eglLookupImage hold the display lock. ==16659== Possible data race during write of size 8 at 0x5D1BCF0 by thread #2668 ==16659== Locks held: 1, at address 0x5D1B6F8 ==16659== at 0x5405DDF: _eglLinkResource (egldisplay.c:454) ==16659== by 0x53F9189: _eglLinkImage (eglimage.h:138) ==16659== by 0x53FE2CA: _eglCreateImageCommon (eglapi.c:1740) ==16659== by 0x53FE39A: eglCreateImageKHR (eglapi.c:1751) ==16659== ==16659== This conflicts with a previous read of size 8 by thread #2664 ==16659== Locks held: 1, at address 0x5308D00 ==16659== at 0x5405C06: _eglCheckResource (egldisplay.c:387) ==16659== by 0x5408C92: _eglLookupImage (eglimage.h:162) ==16659== by 0x5409E96: dri2_lookup_egl_image (egl_dri2.c:688) ==16659== by 0x6210AAF: dri2_lookup_egl_image (dri_helpers.c:250) ==16659== by 0x6212843: dri_get_egl_image (dri_screen.c:470) ==16659== by 0x625F7CC: st_get_egl_image (st_cb_eglimage.c:152) ==16659== by 0x625FE7D: st_egl_image_target_texture_2d (st_cb_eglimage.c:354) ==16659== by 0x6501C05: egl_image_target_texture (teximage.c:3446) Signed-off-by: Tapani Pälli Reviewed-by: Lionel Landwerlin Cc: mesa-stable Part-of: --- src/egl/drivers/dri2/egl_dri2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index a4164cccb8e..337889781d2 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -690,7 +690,10 @@ dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data) (void) screen; + mtx_lock(&disp->Mutex); img = _eglLookupImage(image, disp); + mtx_unlock(&disp->Mutex); + if (img == NULL) { _eglError(EGL_BAD_PARAMETER, "dri2_lookup_egl_image"); return NULL;