[Mesa-stable] [PATCH 2/2] st/mesa: remove redundant stfb->iface checks
Nicolai Hähnle
nhaehnle at gmail.com
Tue Apr 25 09:23:40 UTC 2017
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
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.
---
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 ff18fd0..2158c55 100644
--- a/src/mesa/state_tracker/st_cb_viewport.c
+++ b/src/mesa/state_tracker/st_cb_viewport.c
@@ -47,20 +47,20 @@ static void st_viewport(struct gl_context *ctx)
/*
* Normally we'd want the state tracker manager to mark the drawables
* invalid only when needed. This will force the state tracker manager
* to revalidate the drawable, rather than just update the context with
* the latest cached drawable info.
*/
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)
stread->iface_stamp = p_atomic_read(&stread->iface->stamp) - 1;
}
void st_init_viewport_functions(struct dd_function_table *functions)
{
functions->Viewport = st_viewport;
}
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 2ba7de6..90e4177 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -169,24 +169,20 @@ st_context_validate(struct st_context *st,
static void
st_framebuffer_validate(struct st_framebuffer *stfb,
struct st_context *st)
{
struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
uint width, height;
unsigned i;
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;
/* validate the fb */
do {
if (!stfb->iface->validate(&st->iface, stfb->iface, stfb->statts,
stfb->num_statts, textures))
return;
@@ -274,23 +270,20 @@ st_framebuffer_update_attachments(struct st_framebuffer *stfb)
* corresponds to a window and is not a user-created FBO.
*/
static boolean
st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb,
gl_buffer_index idx)
{
struct gl_renderbuffer *rb;
enum pipe_format format;
boolean sw;
- if (!stfb->iface)
- return FALSE;
-
assert(_mesa_is_winsys_fbo(&stfb->Base));
/* do not distinguish depth/stencil buffers */
if (idx == BUFFER_STENCIL)
idx = BUFFER_DEPTH;
switch (idx) {
case BUFFER_DEPTH:
format = stfb->iface->visual->depth_stencil_format;
sw = FALSE;
--
2.9.3
More information about the mesa-stable
mailing list