[PATCH 3/9] drm/i915: Change mutex initialization in intel_guc_log

Jani Nikula jani.nikula at linux.intel.com
Wed Aug 6 09:06:36 UTC 2025


On Tue, 05 Aug 2025, Luiz Otavio Mello <luiz.mello at estudante.ufscar.br> wrote:
> The intel_guc_log->relay.lock is currently initialized in
> intel_guc_log_init_early(), but it lacks a corresponding destructor,
> which can lead to a memory leak.

That's not quite accurate. The destructor is only relevant for
CONFIG_DEBUG_MUTEXES=y, which ensures the lock is not used after it's
been destroyed. Otherwise it's a nop.

The patch itself makes sense.

BR,
Jani.

>
> This patch replaces the use of mutex_init() with drmm_mutex_init(),
> which ensures the lock is properly destroyed when the driver is
> unloaded.
>
> Signed-off-by: Luiz Otavio Mello <luiz.mello at estudante.ufscar.br>
> ---
>  drivers/gpu/drm/i915/gt/uc/intel_guc_log.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
> index 7135fdb0ebb4..469173791394 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
> @@ -6,6 +6,8 @@
>  #include <linux/debugfs.h>
>  #include <linux/string_helpers.h>
>  
> +#include <drm/drm_managed.h>
> +
>  #include "gt/intel_gt.h"
>  #include "i915_drv.h"
>  #include "i915_irq.h"
> @@ -512,7 +514,10 @@ static void guc_log_relay_unmap(struct intel_guc_log *log)
>  
>  void intel_guc_log_init_early(struct intel_guc_log *log)
>  {
> -	mutex_init(&log->relay.lock);
> +	struct intel_guc *guc = log_to_guc(log);
> +	struct drm_i915_private *i915 = guc_to_i915(guc);
> +
> +	drmm_mutex_init(&i915->drm, &log->relay.lock);
>  	INIT_WORK(&log->relay.flush_work, copy_debug_logs_work);
>  	log->relay.started = false;
>  }

-- 
Jani Nikula, Intel


More information about the Intel-gfx mailing list