[PATCH libdrm] amdgpu: fix off by one in handle_table_insert

Christian König ckoenig.leichtzumerken at gmail.com
Wed Aug 15 11:25:55 UTC 2018


Stupid me, max_key must always be larger than key.

Signed-off-by: Christian König <christian.koenig at amd.com>
---
 amdgpu/handle_table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/amdgpu/handle_table.c b/amdgpu/handle_table.c
index 15cd4763..4fdd29d3 100644
--- a/amdgpu/handle_table.c
+++ b/amdgpu/handle_table.c
@@ -33,7 +33,7 @@ drm_private int handle_table_insert(struct handle_table *table, uint32_t key,
 {
 	if (key >= table->max_key) {
 		uint32_t alignment = sysconf(_SC_PAGESIZE) / sizeof(void*);
-		uint32_t max_key = ALIGN(key, alignment);
+		uint32_t max_key = ALIGN(key + 1, alignment);
 		void **values;
 
 		values = realloc(table->values, max_key * sizeof(void *));
-- 
2.17.1



More information about the amd-gfx mailing list