]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/etnaviv: Fix missing mutex_destroy()
authorSui Jingfeng <sui.jingfeng@linux.dev>
Sun, 8 Sep 2024 12:11:06 +0000 (20:11 +0800)
committerLucas Stach <l.stach@pengutronix.de>
Mon, 28 Oct 2024 15:30:15 +0000 (16:30 +0100)
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 <cgmeiner@igalia.com>
Signed-off-by: Sui Jingfeng <sui.jingfeng@linux.dev>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c
drivers/gpu/drm/etnaviv/etnaviv_drv.c
drivers/gpu/drm/etnaviv/etnaviv_gem.c
drivers/gpu/drm/etnaviv/etnaviv_gpu.c
drivers/gpu/drm/etnaviv/etnaviv_mmu.c

index 721d633aece9d4c81f0019e4c55884f26ee61c60..66a407f1b3ee75484b421cef21846c98502fe9a4 100644 (file)
@@ -55,6 +55,7 @@ etnaviv_cmdbuf_suballoc_new(struct device *dev)
        return suballoc;
 
 free_suballoc:
+       mutex_destroy(&suballoc->lock);
        kfree(suballoc);
 
        return ERR_PTR(ret);
@@ -79,6 +80,7 @@ void etnaviv_cmdbuf_suballoc_destroy(struct etnaviv_cmdbuf_suballoc *suballoc)
 {
        dma_free_wc(suballoc->dev, SUBALLOC_SIZE, suballoc->vaddr,
                    suballoc->paddr);
+       mutex_destroy(&suballoc->lock);
        kfree(suballoc);
 }
 
index 19ec67a5a918e3d8bff49445363ecbda5949e66d..aeacf5863fc86fa5aed56c2cefc92c066471d04c 100644 (file)
@@ -574,6 +574,7 @@ out_unbind:
 out_destroy_suballoc:
        etnaviv_cmdbuf_suballoc_destroy(priv->cmdbuf_suballoc);
 out_free_priv:
+       mutex_destroy(&priv->gem_lock);
        kfree(priv);
 out_put:
        drm_dev_put(drm);
index 63b7e143c273efb72045fa33c9bcef8f49c83169..592a566ea747c34f5bd039077b193b2f479c8af0 100644 (file)
@@ -514,6 +514,7 @@ void etnaviv_gem_free_object(struct drm_gem_object *obj)
        etnaviv_obj->ops->release(etnaviv_obj);
        drm_gem_object_release(obj);
 
+       mutex_destroy(&etnaviv_obj->lock);
        kfree(etnaviv_obj);
 }
 
index 5e753dd42f72106837af1c4d98b444ab7a5a843d..93aa6f762cd25d495b4e384da2fcf140401636aa 100644 (file)
@@ -1921,8 +1921,13 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
 
 static void etnaviv_gpu_platform_remove(struct platform_device *pdev)
 {
+       struct etnaviv_gpu *gpu = dev_get_drvdata(&pdev->dev);
+
        component_del(&pdev->dev, &gpu_ops);
        pm_runtime_disable(&pdev->dev);
+
+       mutex_destroy(&gpu->lock);
+       mutex_destroy(&gpu->sched_lock);
 }
 
 static int etnaviv_gpu_rpm_suspend(struct device *dev)
index 1661d589bf3e7f4acb2ab8d9c1c9e0cb2f95492c..02d9408d41bcf7a821185b2d63d543b1782ceae8 100644 (file)
@@ -358,7 +358,7 @@ static void etnaviv_iommu_context_free(struct kref *kref)
                container_of(kref, struct etnaviv_iommu_context, refcount);
 
        etnaviv_cmdbuf_suballoc_unmap(context, &context->cmdbuf_mapping);
-
+       mutex_destroy(&context->lock);
        context->global->ops->free(context);
 }
 void etnaviv_iommu_context_put(struct etnaviv_iommu_context *context)