From 1a3d75790db3effe6f461ca4923cac7e7d2202c4 Mon Sep 17 00:00:00 2001 From: Amurthyreddy Date: Mon, 24 Sep 2018 13:03:12 +0530 Subject: gpu: nvgpu: QNX devg-nvrm crash fix. Input paran VM Will be used to get PTE size for GVA spaces and it can be NULL if buddy_allocator initialization is not for GVA space. As part of recent changes VM was being accessed for non GVA space case and for that VM was NULL, causing the crash. In this fix added a prior check and VM will be accessed only if input flag is set to GPU_ALLOC_GVA_SPACE. Bug 200452730 Change-Id: I9dcb1f2bd5e639c37a7152b99453bb5b46fe4087 Signed-off-by: Amurthyreddy Reviewed-on: https://git-master.nvidia.com/r/1842530 Reviewed-by: svc-misra-checker Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Tested-by: Prateek Sethi Reviewed-by: Vaibhav Kachore Reviewed-by: Vijayakumar Subbu Reviewed-by: Deepak Nibade Reviewed-by: Alex Waterman --- drivers/gpu/nvgpu/common/mm/buddy_allocator.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c index c0d1335e..0ce9ae8a 100644 --- a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c @@ -1350,11 +1350,13 @@ int nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, * must be PDE aligned. If big_pages are not enabled then this * requirement is not necessary. */ - base_big_page = base & ((vm->big_page_size << 10U) - 1U); - size_big_page = size & ((vm->big_page_size << 10U) - 1U); - if (is_gva_space && vm->big_pages && - (base_big_page != 0ULL || size_big_page != 0ULL)) { - return -EINVAL; + if (is_gva_space) { + base_big_page = base & ((vm->big_page_size << 10U) - 1U); + size_big_page = size & ((vm->big_page_size << 10U) - 1U); + if (vm->big_pages && + (base_big_page != 0ULL || size_big_page != 0ULL)) { + return -EINVAL; + } } a->flags = flags; -- cgit v1.2.2