From 9d346af322e3f9d6d52e00759e8c3cd37c192004 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolai=20H=C3=A4hnle?= Date: Fri, 21 Apr 2017 15:11:34 +0200 Subject: [PATCH] st/mesa: remove redundant stfb->iface checks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit stfb->iface is always non-NULL for an st_framebuffer. These checks were incorrect, relying on out-of-bounds memory access in the surface-less case of EGL_KHR_surfaceless_context. v2: remove redundant stread check (Marek) Reviewed-by: Marek Olšák (v2) --- src/mesa/state_tracker/st_cb_viewport.c | 4 ++-- src/mesa/state_tracker/st_manager.c | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_viewport.c b/src/mesa/state_tracker/st_cb_viewport.c index ff18fd0e6a4..8b50350fabb 100644 --- a/src/mesa/state_tracker/st_cb_viewport.c +++ b/src/mesa/state_tracker/st_cb_viewport.c @@ -54,9 +54,9 @@ static void st_viewport(struct gl_context *ctx) stdraw = st_ws_framebuffer(st->ctx->DrawBuffer); stread = st_ws_framebuffer(st->ctx->ReadBuffer); - if (stdraw && stdraw->iface) + if (stdraw) stdraw->iface_stamp = p_atomic_read(&stdraw->iface->stamp) - 1; - if (stread && stread != stdraw && stread->iface) + if (stread && stread != stdraw) stread->iface_stamp = p_atomic_read(&stread->iface->stamp) - 1; } diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 2ba7de6c634..90e4177f696 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -176,10 +176,6 @@ st_framebuffer_validate(struct st_framebuffer *stfb, boolean changed = FALSE; int32_t new_stamp; - /* Check for incomplete framebuffers (e.g. EGL_KHR_surfaceless_context) */ - if (!stfb->iface) - return; - new_stamp = p_atomic_read(&stfb->iface->stamp); if (stfb->iface_stamp == new_stamp) return; @@ -281,9 +277,6 @@ st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb, enum pipe_format format; boolean sw; - if (!stfb->iface) - return FALSE; - assert(_mesa_is_winsys_fbo(&stfb->Base)); /* do not distinguish depth/stencil buffers */ -- 2.30.2