dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christian Gmeiner" <christian.gmeiner@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/7] drm/etnaviv: Don't set up a GPU on resume that is not initialized
Date: Fri, 20 Nov 2026 10:53:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-224969@kernel.org> (raw)
In-Reply-To: <20261120-etnaviv-gpu-freq-trace-v1-1-445fc6eacddf@igalia.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] drm/etnaviv: dangling pointer in
  etnaviv_flop_reset_ppu_init() [1]
--

commit e39a29696b51cde581759634e80e80a231bf7a60
Author: Christian Gmeiner <cgmeiner@igalia.com>

drm/etnaviv: Don't set up a GPU on resume that is not initialized

This commit resets gpu->state to ETNA_GPU_STATE_UNKNOWN when
etnaviv_gpu_init() fails or during etnaviv_gpu_unbind(), and preserves
that state across runtime suspend so uninitialized GPUs are not set up
on resume.

> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> index 6a4aab75ebba5..2a15ae6135f5e 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> @@ -951,6 +951,8 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
>  	return 0;
>  
>  fail:
> +	/* the GPU is not used, a resume must not set it up */
> +	gpu->state = ETNA_GPU_STATE_UNKNOWN;
>  	pm_runtime_mark_last_busy(gpu->dev);
>  pm_put:
>  	pm_runtime_put_autosuspend(gpu->dev);

[Severity: Critical]
This problem wasn't introduced by this patch, but can a failure in
etnaviv_flop_reset_ppu_init() during etnaviv_gpu_init() leave a dangling
pointer in priv->flop_reset_data_ppu [1]?

drivers/gpu/drm/etnaviv/etnaviv_flop_reset.c:etnaviv_flop_reset_ppu_init() {
	...
	int ret = etnaviv_cmdbuf_init(priv->cmdbuf_suballoc,
				      priv->flop_reset_data_ppu, buffer_size);
	if (ret) {
		kfree(priv->flop_reset_data_ppu);
		return ret;
	}
	...
}

Because load_gpu() ignores errors from etnaviv_gpu_init() and keeps the
DRM device bound, a subsequent GPU core sees a non-NULL
priv->flop_reset_data_ppu, skips initialization, and dereferences the
freed command buffer in etnaviv_flop_reset_ppu_run() (use-after-free).
On device unbind, etnaviv_unbind() also passes the dangling pointer to
etnaviv_cmdbuf_free() and kfree(), causing a double free.

[1] https://sashiko.dev/#/bug/linux-4d0f1113-6871-425a-a512-96f1b1788e33

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-etnaviv-gpu-freq-trace-v1-0-445fc6eacddf@igalia.com?part=1

  reply	other threads:[~2026-11-20 10:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 10:40 [PATCH 0/7] drm/etnaviv: Report GPU clock changes to userspace Christian Gmeiner
2026-11-20 10:40 ` [PATCH 1/7] drm/etnaviv: Don't set up a GPU on resume that is not initialized Christian Gmeiner
2026-11-20 10:53   ` sashiko-bot [this message]
2026-11-20 10:40 ` [PATCH 2/7] drm/etnaviv: Register the cooling device last and unregister it first Christian Gmeiner
2026-11-20 10:40 ` [PATCH 3/7] drm/etnaviv: Skip cooling requests that keep the clock Christian Gmeiner
2026-11-20 10:40 ` [PATCH 4/7] drm/etnaviv: Don't change the clock of a suspended GPU Christian Gmeiner
2026-11-20 10:40 ` [PATCH 5/7] drm/etnaviv: Change the GPU clock between jobs Christian Gmeiner
2026-11-20 10:40 ` [PATCH 6/7] drm/etnaviv: Add a GPU clock change trace event Christian Gmeiner
2026-11-20 10:40 ` [PATCH 7/7] drm/etnaviv: Add an ioctl to read back GPU clock changes Christian Gmeiner

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=sashiko-outbox-224969@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=christian.gmeiner@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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