Commit deadf1ef authored by Sui Jingfeng's avatar Sui Jingfeng Committed by Lucas Stach
Browse files

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: default avatarChristian Gmeiner <cgmeiner@igalia.com>
Signed-off-by: default avatarSui Jingfeng <sui.jingfeng@linux.dev>
Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
parent b09ccba7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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);
}

+1 −0
Original line number Diff line number Diff line
@@ -574,6 +574,7 @@ static int etnaviv_bind(struct device *dev)
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);
+1 −0
Original line number Diff line number Diff line
@@ -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);
}

+5 −0
Original line number Diff line number Diff line
@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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)