gpu: ion: Return correct error code at alloc fail
If we fail to allocate a page from the iommu heap return
correct error code to ensure caller will not use pagees
that did not get allocated.
CRs-fixed: 448796
Change-Id: I0ce086608dc1c97ccf203bcbd2a0baaee905a461
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
diff --git a/drivers/gpu/ion/ion_iommu_heap.c b/drivers/gpu/ion/ion_iommu_heap.c
index cb8fbed..d43f19f 100644
--- a/drivers/gpu/ion/ion_iommu_heap.c
+++ b/drivers/gpu/ion/ion_iommu_heap.c
@@ -82,8 +82,10 @@
for_each_sg(table->sgl, sg, table->nents, i) {
data->pages[i] = alloc_page(
GFP_KERNEL | __GFP_HIGHMEM);
- if (!data->pages[i])
+ if (!data->pages[i]) {
+ ret = -ENOMEM;
goto err3;
+ }
sg_set_page(sg, data->pages[i], PAGE_SIZE, 0);
sg_dma_address(sg) = sg_phys(sg);