nvmap: Fix incorrect deallocator SAST defect

Deallocator vfree is used when kfree should be used. Use nvmap_altfree
earlier and set pages to NULL, to use appropriate deallocator function
and fix 1 ALLOC_FREE_MISMATCH SAST defect.

Bug 4479044

Change-Id: I0257107fcef31271f14775bc3f6354390caf08f0
Signed-off-by: N V S Abhishek <nabhishek@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3118540
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
N V S Abhishek
2024-04-18 10:19:04 +00:00
committed by Jon Hunter
parent efeecacbd1
commit cb2e183b22

View File

@@ -79,9 +79,11 @@ void *__nvmap_mmap(struct nvmap_handle *h)
goto out;
vaddr = vmap(pages, h->size >> PAGE_SHIFT, VM_MAP, prot);
nvmap_altfree(pages, (h->size >> PAGE_SHIFT) * sizeof(*pages));
pages = NULL;
if (!vaddr && !h->vaddr)
goto out;
nvmap_altfree(pages, (h->size >> PAGE_SHIFT) * sizeof(*pages));
if (vaddr && atomic_long_cmpxchg((atomic_long_t *)(void *)&h->vaddr, 0,
(long)vaddr)) {