Mesa (staging/20.2): gallium/dri2: Move image->texture assignment after image NULL check.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Sep 30 16:31:18 UTC 2020
Module: Mesa
Branch: staging/20.2
Commit: 28cff4722da78a41f4b972acd9c437b546713c91
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=28cff4722da78a41f4b972acd9c437b546713c91
Author: Vinson Lee <vlee at freedesktop.org>
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 <vlee at freedesktop.org>
Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6807>
(cherry picked from commit 03e7b75c22c0b3b55820be982ff9d98d704f3260)
---
.pick_status.json | 2 +-
src/gallium/frontends/dri/dri2.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index cc51ee37c1b..478fbbd2eaf 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -2335,7 +2335,7 @@
"description": "gallium/dri2: Move image->texture assignment after image NULL check.",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "ad609bf55a87200ab11ad7cf31420dcfd8dfc141"
},
diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c
index da2a28725e8..8eff860015d 100644
--- a/src/gallium/frontends/dri/dri2.c
+++ b/src/gallium/frontends/dri/dri2.c
@@ -1533,7 +1533,6 @@ dri2_map_image(__DRIcontext *context, __DRIimage *image,
struct dri_context *ctx = dri_context(context);
struct pipe_context *pipe = ctx->st->pipe;
enum pipe_transfer_usage pipe_access = 0;
- struct pipe_resource *resource = image->texture;
struct pipe_transfer *trans;
void *map;
@@ -1544,6 +1543,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;
More information about the mesa-commit
mailing list