gpu: nvgpu: fix memory leak in case of failure

In __gk20a_alloc_pages(), if we fail to allocate a chunk
we free previously allocated chunks in error path
But we do not free up the memory reserved in those chunks
which could lead to OOM situations

Fix this by calling gk20a_free() for each chunk in error
path

Jira DNVGPU-96

Change-Id: I68aa18d68a5282405016e688c790ccbc0c2a0d69
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1203098
(cherry picked from commit f096bd1675600f4e2fc2d686f2911bb945fbbf0b)
Reviewed-on: http://git-master/r/1210952
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
Deepak Nibade
2016-08-16 13:47:43 +05:30
committed by mobile promotions
parent 3b6819bdf4
commit 50fec50bff

View File

@@ -200,6 +200,7 @@ fail_cleanup:
c = list_first_entry(&alloc->alloc_chunks, c = list_first_entry(&alloc->alloc_chunks,
struct page_alloc_chunk, list_entry); struct page_alloc_chunk, list_entry);
list_del(&c->list_entry); list_del(&c->list_entry);
gk20a_free(&a->source_allocator, c->base);
kfree(c); kfree(c);
} }
kfree(alloc); kfree(alloc);