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: ad609bf55a ("frontend/dri: Implement mapping individual planes.")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6807>
(cherry picked from commit 03e7b75c22)
This commit is contained in:
Vinson Lee 2020-09-21 18:20:25 -07:00 committed by Dylan Baker
parent a0238684de
commit 28cff4722d
2 changed files with 2 additions and 2 deletions

View file

@ -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"
},

View file

@ -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;