Skip to contentSkip to conversation

drm/amdkfd: kfree the wrong pointer

PATCH In review Jack Zhang 3 participants 3 messages Apr 1, 2020

Subsystems (3)
lore
Share & tools
lore

Jack Zhang

author
#0 lore raw

PATCH 1/1 drm/amdkfd: kfree the wrong pointer

Originally, it kfrees the wrong pointer for mem_obj. It would cause memory leak under stress test.

---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +2 -2
index 7866cd06..0491ab2 100644
@@ -1134,9 +1134,9 @@ int kfd_gtt_sa_allocate(struct kfd_dev *kfd, unsigned int size,
 	return 0;
 
 kfd_gtt_no_free_chunk:
-	pr_debug("Allocation failed with mem_obj = %p\n", mem_obj);
+	pr_debug("Allocation failed with mem_obj = %p\n", *mem_obj);
 	mutex_unlock(&kfd->gtt_sa_lock);
-	kfree(mem_obj);
+	kfree(*mem_obj);
 	return -ENOMEM;
 }
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Acked-by Nirmoy Das on v1 1/1
#1 lore raw
Quoted 4 lines · Jack Zhang

Originally, it kfrees the wrong pointer for mem_obj. It would cause memory leak under stress test.

Quoted 10 lines
---
  drivers/gpu/drm/amd/amdkfd/kfd_device.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +0 -0
index 7866cd06..0491ab2 100644
@@ -1134,9 +1134,9 @@ int kfd_gtt_sa_allocate(struct kfd_dev *kfd, unsigned int size,
  	return 0;

drivers/gpu/drm/amd/amdkfd/kfd_device.c int kfd_gtt_sa_allocate(struct kfd_dev *kfd, unsigned int size, · line 1142

Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_device.c +2 -2
 
  kfd_gtt_no_free_chunk:
-	pr_debug("Allocation failed with mem_obj = %p\n", mem_obj);
+	pr_debug("Allocation failed with mem_obj = %p\n", *mem_obj);
  	mutex_unlock(&kfd->gtt_sa_lock);
-	kfree(mem_obj);
+	kfree(*mem_obj);
  	return -ENOMEM;
  }
 

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

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Jack Zhang

Am 2020-04-01 um 8:12 a.m. schrieb Jack Zhang:

Quoted 4 lines

Originally, it kfrees the wrong pointer for mem_obj. It would cause memory leak under stress test.

Thanks for catching this. Did you actually run into this code path? In that case we may also need to increase the GTT memory reserved for this suballocator.

Thanks,
  Felix

Quoted 10 lines
---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +0 -0
index 7866cd06..0491ab2 100644
@@ -1134,9 +1134,9 @@ int kfd_gtt_sa_allocate(struct kfd_dev *kfd, unsigned int size,
 	return 0;

drivers/gpu/drm/amd/amdkfd/kfd_device.c int kfd_gtt_sa_allocate(struct kfd_dev *kfd, unsigned int size, · line 1142

Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_device.c +2 -2
 
 kfd_gtt_no_free_chunk:
-	pr_debug("Allocation failed with mem_obj = %p\n", mem_obj);
+	pr_debug("Allocation failed with mem_obj = %p\n", *mem_obj);
 	mutex_unlock(&kfd->gtt_sa_lock);
-	kfree(mem_obj);
+	kfree(*mem_obj);
 	return -ENOMEM;
 }
 

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