From 931edb9d5265b9855ae98ebefaae1113eae16249 Mon Sep 17 00:00:00 2001 From: Vedashree Vidwans Date: Fri, 5 Apr 2019 14:29:29 -0700 Subject: [PATCH] gpu: nvgpu: free slabs in page_allocator_init fail Currently, nvgpu_page_allocator_init() doesn't free allocated slabs if function fails initializing buddy_allocator. This patch frees allocated slabs in fail path. Jira NVGPU-3107 Change-Id: I17d735e7d664c1ddcbeab04129c4baca1581fe1e Signed-off-by: Vedashree Vidwans Reviewed-on: https://git-master.nvidia.com/r/2092769 Reviewed-by: svc-misra-checker GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/allocators/page_allocator.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/nvgpu/common/mm/allocators/page_allocator.c b/drivers/gpu/nvgpu/common/mm/allocators/page_allocator.c index 7fd67ca77..dbbab1621 100644 --- a/drivers/gpu/nvgpu/common/mm/allocators/page_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/allocators/page_allocator.c @@ -1085,6 +1085,9 @@ int nvgpu_page_allocator_init(struct gk20a *g, struct nvgpu_allocator *na, return 0; fail: + if (a->slabs != NULL) { + nvgpu_kfree(g, a->slabs); + } if (a->alloc_cache != NULL) { nvgpu_kmem_cache_destroy(a->alloc_cache); }