Skip to contentSkip to conversation

amdgpu: fix off by one in handle_table_insert

PATCH In review Christian König 3 participants 3 messages Aug 15, 2018 – Aug 16, 2018 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amdgpu: fix off by one in handle_table_insert

Stupid me, max_key must always be larger than key.

---
 amdgpu/handle_table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
amdgpu/handle_table.c +1 -1
index 15cd4763..4fdd29d3 100644
@@ -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 *));
Signature · 6 lines
2.17.1

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

A message that is not in the archive (sent off-list or not yet received): 20180815112555.3240-1-christian.koenig-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 13 lines · Christian König

Stupid me, max_key must always be larger than key.

---
 amdgpu/handle_table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
amdgpu/handle_table.c +0 -0
index 15cd4763..4fdd29d3 100644

amdgpu/handle_table.c drm_private int handle_table_insert(struct handle_table *table, uint32_t key, · line 39

Quoted 8 lines
amdgpu/handle_table.c +1 -1
@@ -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 *));

Good catch! Looks like you can add

Bugzilla: https://bugs.freedesktop.org/107552

as well as

before pushing.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by Junwei Zhang
#3 lore raw
In reply to a message not in the archive
Quoted 3 lines · Christian König

Stupid me, max_key must always be larger than key.

Good catch

Quoted 10 lines
---
  amdgpu/handle_table.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
amdgpu/handle_table.c +0 -0
index 15cd4763..4fdd29d3 100644

amdgpu/handle_table.c drm_private int handle_table_insert(struct handle_table *table, uint32_t key, · line 39

Quoted 8 lines
amdgpu/handle_table.c +1 -1
@@ -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 *));

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