Commit d23a6e3f authored by Maíra Canal's avatar Maíra Canal Committed by Melissa Wen
Browse files

drm/v3d: add missing mutex_destroy



v3d_perfmon_open_file() instantiates a mutex for a particular file
instance, but it never destroys it by calling mutex_destroy() in
v3d_perfmon_close_file().

Similarly, v3d_perfmon_create_ioctl() instantiates a mutex for a
particular perfmon, but it never destroys it by calling mutex_destroy()
in v3d_perfmon_destroy_ioctl().

So, add the missing mutex_destroy on both cases.

Signed-off-by: default avatarMaíra Canal <mcanal@igalia.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarMelissa Wen <melissa.srw@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221108175425.39819-3-mcanal@igalia.com
parent 91d502f6
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -17,9 +17,11 @@ void v3d_perfmon_get(struct v3d_perfmon *perfmon)


void v3d_perfmon_put(struct v3d_perfmon *perfmon)
void v3d_perfmon_put(struct v3d_perfmon *perfmon)
{
{
	if (perfmon && refcount_dec_and_test(&perfmon->refcnt))
	if (perfmon && refcount_dec_and_test(&perfmon->refcnt)) {
		mutex_destroy(&perfmon->lock);
		kfree(perfmon);
		kfree(perfmon);
	}
	}
}


void v3d_perfmon_start(struct v3d_dev *v3d, struct v3d_perfmon *perfmon)
void v3d_perfmon_start(struct v3d_dev *v3d, struct v3d_perfmon *perfmon)
{
{
@@ -113,6 +115,7 @@ void v3d_perfmon_close_file(struct v3d_file_priv *v3d_priv)
	idr_for_each(&v3d_priv->perfmon.idr, v3d_perfmon_idr_del, NULL);
	idr_for_each(&v3d_priv->perfmon.idr, v3d_perfmon_idr_del, NULL);
	idr_destroy(&v3d_priv->perfmon.idr);
	idr_destroy(&v3d_priv->perfmon.idr);
	mutex_unlock(&v3d_priv->perfmon.lock);
	mutex_unlock(&v3d_priv->perfmon.lock);
	mutex_destroy(&v3d_priv->perfmon.lock);
}
}


int v3d_perfmon_create_ioctl(struct drm_device *dev, void *data,
int v3d_perfmon_create_ioctl(struct drm_device *dev, void *data,
@@ -154,6 +157,7 @@ int v3d_perfmon_create_ioctl(struct drm_device *dev, void *data,
	mutex_unlock(&v3d_priv->perfmon.lock);
	mutex_unlock(&v3d_priv->perfmon.lock);


	if (ret < 0) {
	if (ret < 0) {
		mutex_destroy(&perfmon->lock);
		kfree(perfmon);
		kfree(perfmon);
		return ret;
		return ret;
	}
	}