summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2016-01-25 12:41:05 +0100
committerLucas Stach <l.stach@pengutronix.de>2016-01-26 18:53:59 +0100
commit45d16a6d94580cd3c6baed69b5fe441ece599fc4 (patch)
treecf7346bbbd87f39608ef54b221a055df67a25499 /drivers
parent602eb48966d7b7f7e64dca8d9ea2842d83bfae73 (diff)
drm/etnaviv: fix memory leak in IOMMU init path
Plug in error handling to free any allocated ressources in the IOMMU init path. Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_gpu.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index 7b511ad9f54b..a33162cf4f4c 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -596,10 +596,9 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
goto fail;
}
- /* TODO: we will leak here memory - fix it! */
-
gpu->mmu = etnaviv_iommu_new(gpu, iommu, version);
if (!gpu->mmu) {
+ iommu_domain_free(iommu);
ret = -ENOMEM;
goto fail;
}
@@ -609,7 +608,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
if (!gpu->buffer) {
ret = -ENOMEM;
dev_err(gpu->dev, "could not create command buffer\n");
- goto fail;
+ goto destroy_iommu;
}
if (gpu->buffer->paddr - gpu->memory_base > 0x80000000) {
ret = -EINVAL;
@@ -639,6 +638,9 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
free_buffer:
etnaviv_gpu_cmdbuf_free(gpu->buffer);
gpu->buffer = NULL;
+destroy_iommu:
+ etnaviv_iommu_destroy(gpu->mmu);
+ gpu->mmu = NULL;
fail:
pm_runtime_mark_last_busy(gpu->dev);
pm_runtime_put_autosuspend(gpu->dev);