Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Summers, Stuart" <stuart.summers@intel.com>
To: "simona@ffwll.ch" <simona@ffwll.ch>,
	"Vivi, Rodrigo" <rodrigo.vivi@intel.com>,
	"christophe.jaillet@wanadoo.fr" <christophe.jaillet@wanadoo.fr>,
	"De Marchi, Lucas" <lucas.demarchi@intel.com>,
	"thomas.hellstrom@linux.intel.com"
	<thomas.hellstrom@linux.intel.com>,
	"airlied@gmail.com" <airlied@gmail.com>
Cc: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/xe/hwmon: Use devm_mutex_init()
Date: Mon, 8 Sep 2025 18:47:33 +0000	[thread overview]
Message-ID: <99686467b8d528b0bc9967989ef75df2fc6d1797.camel@intel.com> (raw)
In-Reply-To: <989e96369e9e1f8a44b816962917ec76877c912d.1757252520.git.christophe.jaillet@wanadoo.fr>

On Sun, 2025-09-07 at 15:42 +0200, Christophe JAILLET wrote:
> Use devm_mutex_init() instead of hand-writing it.
> 
> This saves some LoC, improves readability and saves some space in the
> generated .o file.
> 
> Before:
> ======
>    text    data     bss     dec     hex filename
>   36884   10296      64   47244    b88c drivers/gpu/drm/xe/xe_hwmon.o
> 
> After:
> =====
>    text    data     bss     dec     hex filename
>   36651   10224      64   46939    b75b drivers/gpu/drm/xe/xe_hwmon.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/gpu/drm/xe/xe_hwmon.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c
> b/drivers/gpu/drm/xe/xe_hwmon.c
> index 32a76ae6e9dc..e65382d4426a 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
> @@ -1294,13 +1294,6 @@ xe_hwmon_get_preregistration_info(struct
> xe_hwmon *hwmon)
>                         xe_hwmon_fan_input_read(hwmon, channel,
> &fan_speed);
>  }
>  
> -static void xe_hwmon_mutex_destroy(void *arg)
> -{
> -       struct xe_hwmon *hwmon = arg;
> -
> -       mutex_destroy(&hwmon->hwmon_lock);
> -}
> -
>  int xe_hwmon_register(struct xe_device *xe)
>  {
>         struct device *dev = xe->drm.dev;
> @@ -1319,8 +1312,7 @@ int xe_hwmon_register(struct xe_device *xe)
>         if (!hwmon)
>                 return -ENOMEM;
>  
> -       mutex_init(&hwmon->hwmon_lock);
> -       ret = devm_add_action_or_reset(dev, xe_hwmon_mutex_destroy,
> hwmon);
> +       ret = devm_mutex_init(dev, &hwmon->hwmon_lock);

Thanks for the patch! Yes I agree this looks better. And we don't want
to use drmm_mutex_init() here because, as was detailed in an earlier
fix here, we can't mix devm_kzalloc with drmm_mutex_init or risk a uaf.

Reviewed-by: Stuart Summers <stuart.summers@intel.com>

>         if (ret)
>                 return ret;
>  


  reply	other threads:[~2025-09-08 18:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-07 13:42 [PATCH] drm/xe/hwmon: Use devm_mutex_init() Christophe JAILLET
2025-09-08 18:47 ` Summers, Stuart [this message]
2025-09-08 21:18 ` ✓ CI.KUnit: success for " Patchwork
2025-09-08 21:56 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-09  2:11 ` ✗ Xe.CI.Full: failure " Patchwork
2025-09-09 13:40 ` [PATCH] " Lucas De Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=99686467b8d528b0bc9967989ef75df2fc6d1797.camel@intel.com \
    --to=stuart.summers@intel.com \
    --cc=airlied@gmail.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.demarchi@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=simona@ffwll.ch \
    --cc=thomas.hellstrom@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox