All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harish Chegondi <harish.chegondi@intel.com>
To: Shuicheng Lin <shuicheng.lin@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH] drm/xe/eustall: Fix drm_dev_put called before stream disable in close
Date: Thu, 16 Apr 2026 10:47:00 -0700	[thread overview]
Message-ID: <aeEglIEXfPo40zvU@intel.com> (raw)
In-Reply-To: <20260415225428.3399934-1-shuicheng.lin@intel.com>

On Wed, Apr 15, 2026 at 10:54:28PM +0000, Shuicheng Lin wrote:
> In xe_eu_stall_stream_close(), drm_dev_put() is called before the
> stream is disabled and its resources are freed. If this drops the
> last reference, the device structures could be freed while the
> subsequent cleanup code still accesses them, leading to a
> use-after-free.
> 
> Fix this by moving drm_dev_put() after all device accesses are
> complete. This matches the ordering in xe_oa_release().
> 
> Fixes: 9a0b11d4cf3b ("drm/xe/eustall: Add support to init, enable and disable EU stall sampling")
> Cc: Harish Chegondi <harish.chegondi@intel.com>
> Assisted-by: Claude:claude-opus-4.6
> Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>

Reviewed-by: Harish Chegondi <harish.chegondi@intel.com>

Thanks for the patch!

> ---
>  drivers/gpu/drm/xe/xe_eu_stall.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_eu_stall.c b/drivers/gpu/drm/xe/xe_eu_stall.c
> index aaf3fcc12363..b88b6c49c54a 100644
> --- a/drivers/gpu/drm/xe/xe_eu_stall.c
> +++ b/drivers/gpu/drm/xe/xe_eu_stall.c
> @@ -871,14 +871,14 @@ static int xe_eu_stall_stream_close(struct inode *inode, struct file *file)
>  	struct xe_eu_stall_data_stream *stream = file->private_data;
>  	struct xe_gt *gt = stream->gt;
>  
> -	drm_dev_put(&gt->tile->xe->drm);
> -
>  	mutex_lock(&gt->eu_stall->stream_lock);
>  	xe_eu_stall_disable_locked(stream);
>  	xe_eu_stall_data_buf_destroy(stream);
>  	xe_eu_stall_stream_free(stream);
>  	mutex_unlock(&gt->eu_stall->stream_lock);
>  
> +	drm_dev_put(&gt->tile->xe->drm);
> +
>  	return 0;
>  }
>  
> -- 
> 2.43.0
> 

      parent reply	other threads:[~2026-04-16 17:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-15 22:54 [PATCH] drm/xe/eustall: Fix drm_dev_put called before stream disable in close Shuicheng Lin
2026-04-15 23:03 ` ✗ CI.checkpatch: warning for " Patchwork
2026-04-15 23:04 ` ✓ CI.KUnit: success " Patchwork
2026-04-15 23:55 ` ✓ Xe.CI.BAT: " Patchwork
2026-04-16  1:44 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-04-16 20:09   ` Matt Roper
2026-04-16 17:47 ` Harish Chegondi [this message]

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=aeEglIEXfPo40zvU@intel.com \
    --to=harish.chegondi@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=shuicheng.lin@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.