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>
This commit is contained in:
Kary Jin
2019-05-22 17:10:47 +08:00
committed by mobile promotions
parent 1f867543da
commit fea9e05454

View File

@@ -755,6 +755,11 @@ int nvgpu_vm_get_buffers(struct vm_gk20a *vm,
nvgpu_mutex_acquire(&vm->update_gmmu_lock); nvgpu_mutex_acquire(&vm->update_gmmu_lock);
if (vm->num_user_mapped_buffers == 0) {
nvgpu_mutex_release(&vm->update_gmmu_lock);
return 0;
}
buffer_list = nvgpu_big_zalloc(vm->mm->g, sizeof(*buffer_list) * buffer_list = nvgpu_big_zalloc(vm->mm->g, sizeof(*buffer_list) *
vm->num_user_mapped_buffers); vm->num_user_mapped_buffers);
if (buffer_list == NULL) { if (buffer_list == NULL) {