Skip to content

Commit deadf1e

Browse files
suijingfenglynxeye-dev
authored andcommitted
drm/etnaviv: Fix missing mutex_destroy()
Currently, the calling of mutex_destroy() is ignored on error handling code path. It is safe for now, since mutex_destroy() actually does nothing in non-debug builds. But the mutex_destroy() is used to mark the mutex uninitialized on debug builds, and any subsequent use of the mutex is forbidden. It also could lead to problems if mutex_destroy() gets extended, add missing mutex_destroy() to eliminate potential concerns. Reviewed-by: Christian Gmeiner <[email protected]> Signed-off-by: Sui Jingfeng <[email protected]> Signed-off-by: Lucas Stach <[email protected]>
1 parent b09ccba commit deadf1e

File tree

5 files changed

+10
-1
lines changed

5 files changed

+10
-1
lines changed

drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ etnaviv_cmdbuf_suballoc_new(struct device *dev)
5555
return suballoc;
5656

5757
free_suballoc:
58+
mutex_destroy(&suballoc->lock);
5859
kfree(suballoc);
5960

6061
return ERR_PTR(ret);
@@ -79,6 +80,7 @@ void etnaviv_cmdbuf_suballoc_destroy(struct etnaviv_cmdbuf_suballoc *suballoc)
7980
{
8081
dma_free_wc(suballoc->dev, SUBALLOC_SIZE, suballoc->vaddr,
8182
suballoc->paddr);
83+
mutex_destroy(&suballoc->lock);
8284
kfree(suballoc);
8385
}
8486

drivers/gpu/drm/etnaviv/etnaviv_drv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ static int etnaviv_bind(struct device *dev)
574574
out_destroy_suballoc:
575575
etnaviv_cmdbuf_suballoc_destroy(priv->cmdbuf_suballoc);
576576
out_free_priv:
577+
mutex_destroy(&priv->gem_lock);
577578
kfree(priv);
578579
out_put:
579580
drm_dev_put(drm);

drivers/gpu/drm/etnaviv/etnaviv_gem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ void etnaviv_gem_free_object(struct drm_gem_object *obj)
514514
etnaviv_obj->ops->release(etnaviv_obj);
515515
drm_gem_object_release(obj);
516516

517+
mutex_destroy(&etnaviv_obj->lock);
517518
kfree(etnaviv_obj);
518519
}
519520

drivers/gpu/drm/etnaviv/etnaviv_gpu.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,8 +1921,13 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
19211921

19221922
static void etnaviv_gpu_platform_remove(struct platform_device *pdev)
19231923
{
1924+
struct etnaviv_gpu *gpu = dev_get_drvdata(&pdev->dev);
1925+
19241926
component_del(&pdev->dev, &gpu_ops);
19251927
pm_runtime_disable(&pdev->dev);
1928+
1929+
mutex_destroy(&gpu->lock);
1930+
mutex_destroy(&gpu->sched_lock);
19261931
}
19271932

19281933
static int etnaviv_gpu_rpm_suspend(struct device *dev)

drivers/gpu/drm/etnaviv/etnaviv_mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static void etnaviv_iommu_context_free(struct kref *kref)
358358
container_of(kref, struct etnaviv_iommu_context, refcount);
359359

360360
etnaviv_cmdbuf_suballoc_unmap(context, &context->cmdbuf_mapping);
361-
361+
mutex_destroy(&context->lock);
362362
context->global->ops->free(context);
363363
}
364364
void etnaviv_iommu_context_put(struct etnaviv_iommu_context *context)

0 commit comments

Comments
 (0)