linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/panfrost: Fix leak when free gem object
@ 2025-07-10  3:05 lihongtao
  2025-07-17 10:23 ` Steven Price
  2025-07-17 10:50 ` Markus Elfring
  0 siblings, 2 replies; 3+ messages in thread
From: lihongtao @ 2025-07-10  3:05 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Rob Herring, Steven Price, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, dri-devel,
	linux-kernel, lihongtao

obj->mappings.lock should be destroyed when free
panfrost gem object in panfrost_gem_free_object.

Signed-off-by: lihongtao <lihongtao@kylinos.cn>
---
 drivers/gpu/drm/panfrost/panfrost_gem.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
index 963f04ba2de6..00549f482eec 100644
--- a/drivers/gpu/drm/panfrost/panfrost_gem.c
+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
@@ -49,6 +49,7 @@ static void panfrost_gem_free_object(struct drm_gem_object *obj)
 		kvfree(bo->sgts);
 	}
 
+	mutex_destroy(&bo->mappings.lock);
 	drm_gem_shmem_free(&bo->base);
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/panfrost: Fix leak when free gem object
  2025-07-10  3:05 [PATCH] drm/panfrost: Fix leak when free gem object lihongtao
@ 2025-07-17 10:23 ` Steven Price
  2025-07-17 10:50 ` Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Price @ 2025-07-17 10:23 UTC (permalink / raw)
  To: lihongtao, Boris Brezillon
  Cc: Rob Herring, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, dri-devel, linux-kernel

On 10/07/2025 04:05, lihongtao wrote:
> obj->mappings.lock should be destroyed when free
> panfrost gem object in panfrost_gem_free_object.

mutex_destroy() doesn't actually release any resources. It is purely a
debugging feature (if CONFIG_DEBUG_MUTEXES is disabled then it is
compiled away completely).

So it's not a "leak" as such. But there is some value in using it as it
would (in debug builds) warn us if we attempt to destroy a locked mutex
or attempt to use a mutex after the destroy.

But if we're going to fix this I think we should be more complete. A
quick grep should we have 6 different mutexes in panfrost:

panfrost_device.c:      mutex_init(&pfdev->sched_lock);
panfrost_device.c:      mutex_init(&pfdev->debugfs.gems_lock);
panfrost_drv.c: mutex_init(&pfdev->shrinker_lock);
panfrost_gem.c: mutex_init(&obj->mappings.lock);
panfrost_gem.c: mutex_init(&obj->label.lock);
panfrost_perfcnt.c:     mutex_init(&perfcnt->lock);

But there's only one existing call to mutex_destroy():

panfrost_gem.c: mutex_destroy(&bo->label.lock);

It would be good to consider if the other mutexes should also be destroyed.

Thanks,
Steve

> 
> Signed-off-by: lihongtao <lihongtao@kylinos.cn>
> ---
>  drivers/gpu/drm/panfrost/panfrost_gem.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
> index 963f04ba2de6..00549f482eec 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_gem.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
> @@ -49,6 +49,7 @@ static void panfrost_gem_free_object(struct drm_gem_object *obj)
>  		kvfree(bo->sgts);
>  	}
>  
> +	mutex_destroy(&bo->mappings.lock);
>  	drm_gem_shmem_free(&bo->base);
>  }
>  


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/panfrost: Fix leak when free gem object
  2025-07-10  3:05 [PATCH] drm/panfrost: Fix leak when free gem object lihongtao
  2025-07-17 10:23 ` Steven Price
@ 2025-07-17 10:50 ` Markus Elfring
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2025-07-17 10:50 UTC (permalink / raw)
  To: lihongtao, dri-devel
  Cc: LKML, Boris Brezillon, David Airlie, Maarten Lankhorst,
	Maxime Ripard, Rob Herring, Steven Price, Simona Vetter,
	Thomas Zimmermann

> obj->mappings.lock should be destroyed when free
> panfrost gem object in panfrost_gem_free_object.

How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.16-rc6#n94

Regards,
Markus

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-17 10:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10  3:05 [PATCH] drm/panfrost: Fix leak when free gem object lihongtao
2025-07-17 10:23 ` Steven Price
2025-07-17 10:50 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).