summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKary Jin <karyj@nvidia.com>2019-05-22 05:10:47 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2019-05-31 01:17:11 -0400
commitfea9e054547fc0408eb6c5ca893e5b112e19397b (patch)
tree42090ef4d8019111cf9913b4aff2f4fb03911e9e
parent1f867543daece1ec529211d6d66c9799eab6220f (diff)
gpu: nvgpu: add check for "vm->num_user_mapped_buffers"
The "nvgpu_big_zalloc()" will be failed if the passed-in argument "vm->num_user_mapped_buffers" is zero. The returned value is 16 which will bypass the NULL-check and then causes the panic. This patch adds a check on the "vm->num_user_mapped_buffers" to avoid the zero is passed-in the "nvgpu_big_zalloc()". Bug 2603292 Change-Id: I399eecf72a288e13992730651a34a6cea1ef56d1 Signed-off-by: Kary Jin <karyj@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2123499 GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: Daniel Fu <danifu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/common/mm/vm.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c
index 4e221500..dc928e18 100644
--- a/drivers/gpu/nvgpu/common/mm/vm.c
+++ b/drivers/gpu/nvgpu/common/mm/vm.c
@@ -755,6 +755,11 @@ int nvgpu_vm_get_buffers(struct vm_gk20a *vm,
755 755
756 nvgpu_mutex_acquire(&vm->update_gmmu_lock); 756 nvgpu_mutex_acquire(&vm->update_gmmu_lock);
757 757
758 if (vm->num_user_mapped_buffers == 0) {
759 nvgpu_mutex_release(&vm->update_gmmu_lock);
760 return 0;
761 }
762
758 buffer_list = nvgpu_big_zalloc(vm->mm->g, sizeof(*buffer_list) * 763 buffer_list = nvgpu_big_zalloc(vm->mm->g, sizeof(*buffer_list) *
759 vm->num_user_mapped_buffers); 764 vm->num_user_mapped_buffers);
760 if (buffer_list == NULL) { 765 if (buffer_list == NULL) {