Module: Mesa
Branch: master
Commit: 03e7b75c22c0b3b55820be982ff9d98d704f3260
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=03e7b75c22c0b3b55820be982ff9d98d704f3260

Author: Vinson Lee <[email protected]>
Date:   Mon Sep 21 18:20:25 2020 -0700

gallium/dri2: Move image->texture assignment after image NULL check.

Fix defect reported by Coverity Scan.

Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking image suggests that it may be
null, but it has already been dereferenced on all paths leading to
the check.

Fixes: ad609bf55a87 ("frontend/dri: Implement mapping individual planes.")
Signed-off-by: Vinson Lee <[email protected]>
Reviewed-by: Tapani Pälli <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6807>

---

 src/gallium/frontends/dri/dri2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c
index fa5009c40a5..aab9c8cca3c 100644
--- a/src/gallium/frontends/dri/dri2.c
+++ b/src/gallium/frontends/dri/dri2.c
@@ -1559,7 +1559,6 @@ dri2_map_image(__DRIcontext *context, __DRIimage *image,
    struct dri_context *ctx = dri_context(context);
    struct pipe_context *pipe = ctx->st->pipe;
    enum pipe_map_flags pipe_access = 0;
-   struct pipe_resource *resource = image->texture;
    struct pipe_transfer *trans;
    void *map;
 
@@ -1570,6 +1569,7 @@ dri2_map_image(__DRIcontext *context, __DRIimage *image,
    if (plane >= dri2_get_mapping_by_format(image->dri_format)->nplanes)
       return NULL;
 
+   struct pipe_resource *resource = image->texture;
    while (plane--)
       resource = resource->next;
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to