[Intel-xe] [PATCH] drm/xe: Use kvmalloc_array() instead of kmalloc()
Niranjana Vishwanathapura
niranjana.vishwanathapura at intel.com
Sat Jul 22 07:52:24 UTC 2023
Use kvmalloc_array() instead of kmalloc() to avoid
memory allocation failure in xe_vma_userptr_pin_pages().
Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura at intel.com>
---
drivers/gpu/drm/xe/xe_vm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 62a99c393d6b..6429d6e5113d 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -72,7 +72,7 @@ int xe_vma_userptr_pin_pages(struct xe_vma *vma)
if (notifier_seq == vma->userptr.notifier_seq)
return 0;
- pages = kmalloc(sizeof(*pages) * num_pages, GFP_KERNEL);
+ pages = kvmalloc_array(num_pages, sizeof(*pages), GFP_KERNEL);
if (!pages)
return -ENOMEM;
@@ -152,7 +152,7 @@ int xe_vma_userptr_pin_pages(struct xe_vma *vma)
out:
release_pages(pages, pinned);
- kfree(pages);
+ kvfree(pages);
if (!(ret < 0)) {
vma->userptr.notifier_seq = notifier_seq;
--
2.21.0.rc0.32.g243a4c7e27
More information about the Intel-xe
mailing list