Skip to contentSkip to conversation

drm/etnaviv: fix missing unlock on error in etnaviv_iommuv1_context_alloc()

PATCH Applied Wei Yongjun 2 participants 2 messages Aug 19, 2019 – Sep 2, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/etnaviv: fix missing unlock on error in etnaviv_iommuv1_context_alloc()

Add the missing unlock before return from function etnaviv_iommuv1_context_alloc() in the error handling case.

Fixes 27b67278e007 ("drm/etnaviv: rework MMU handling")
---
 drivers/gpu/drm/etnaviv/etnaviv_iommu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/etnaviv/etnaviv_iommu.c +3 -1
index aac8dbf3ea56..1a7c89a67bea 100644
@@ -140,8 +140,10 @@ etnaviv_iommuv1_context_alloc(struct etnaviv_iommu_global *global)
 	}
 
 	v1_context = kzalloc(sizeof(*v1_context), GFP_KERNEL);
-	if (!v1_context)
+	if (!v1_context) {
+		mutex_unlock(&global->lock);
 		return NULL;
+	}
 
 	v1_context->pgtable_cpu = dma_alloc_wc(global->dev, PT_SIZE,
 					       &v1_context->pgtable_dma,
maintainer Applied
#1 lore raw
Quoted 6 lines · Wei Yongjun

Add the missing unlock before return from function etnaviv_iommuv1_context_alloc()
in the error handling case.

Fixes 27b67278e007 ("drm/etnaviv: rework MMU handling")

Thanks, applied.

For my education, can you tell me which tool you did use to catch this issue?

Regards,
Lucas

Quoted 26 lines
---
 drivers/gpu/drm/etnaviv/etnaviv_iommu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/etnaviv/etnaviv_iommu.c +3 -1
index aac8dbf3ea56..1a7c89a67bea 100644
@@ -140,8 +140,10 @@ etnaviv_iommuv1_context_alloc(struct
 etnaviv_iommu_global *global)
 	}
 
 	v1_context = kzalloc(sizeof(*v1_context), GFP_KERNEL);
-	if (!v1_context)
+	if (!v1_context) {
+		mutex_unlock(&global->lock);
 		return NULL;
+	}
 
 	v1_context->pgtable_cpu = dma_alloc_wc(global->dev, PT_SIZE,

&v1_context-

Quoted 1 line

pgtable_dma,