From ce04ac4e54d6c4e84e9ebeca8e47b806a34a6ccc Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 21 Apr 2021 10:14:13 +0200 Subject: [PATCH] zink: do not read outside of array We need to bounds-check *before* we index the array, otherwise we peek beyond the end of it. Caught by Valgrind. Fixes: dd29a7e5b0e ("zink: move descriptor barrier handling to main update function") Reviewed-By: Mike Blumenkrantz Part-of: (cherry picked from commit a6a198da2196743edda3f01054543909f5da4f8d) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_descriptors.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index f15d62d2560..8f2959cdea4 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -94,7 +94,7 @@ "description": "zink: do not read outside of array", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "dd29a7e5b0ec289a8de978b5ad44e8fe7d1760ac" }, diff --git a/src/gallium/drivers/zink/zink_descriptors.c b/src/gallium/drivers/zink/zink_descriptors.c index 2ed08a765a8..758ff90e53f 100644 --- a/src/gallium/drivers/zink/zink_descriptors.c +++ b/src/gallium/drivers/zink/zink_descriptors.c @@ -1224,7 +1224,7 @@ zink_descriptors_update(struct zink_context *ctx, struct zink_screen *screen, bo is_compute, cache_hit[ZINK_DESCRIPTOR_TYPE_IMAGE], need_resource_refs[ZINK_DESCRIPTOR_TYPE_IMAGE]); - for (int h = 0; zds[h] && h < ZINK_DESCRIPTOR_TYPES; h++) { + for (int h = 0; h < ZINK_DESCRIPTOR_TYPES && zds[h]; h++) { /* skip null descriptor sets since they have no resources */ if (!zds[h]->hash) continue;