All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maxime Ripard" <mripard@kernel.org>
Cc: wsa+renesas@sang-engineering.com, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 35/40] drm/rz-du: Convert to atomic_create_state
Date: Mon, 31 Aug 2026 22:39:35 +0000	[thread overview]
Message-ID: <20260831223936.049AE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831-drm-no-more-plane-reset-v3-35-1877c7aa57b3@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Invalid pointer dereference on initialization error path due to incorrect list iterator usage.
--

commit 3bffdb77add6a2ca9d3e5bb1dea2bfe6e12b39b0
Author: Maxime Ripard <mripard@kernel.org>
Subject: drm/rz-du: Convert to atomic_create_state

This commit converts the plane reset implementation to use atomic_create_state
by creating a pristine state without resetting hardware. The conversion was
done using a Coccinelle semantic patch.

> diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_vsp.c b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_vsp.c
> index 1efa0f0451fe9..944bc9ac9589d 100644
> --- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_vsp.c
> +++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_vsp.c
> @@ -266,26 +266,23 @@ static void rzg2l_du_vsp_plane_atomic_destroy_state(struct drm_plane *plane,

[ ... ]

>  static const struct drm_plane_funcs rzg2l_du_vsp_plane_funcs = {
>  	.update_plane = drm_atomic_helper_update_plane,
>  	.disable_plane = drm_atomic_helper_disable_plane,
> -	.reset = rzg2l_du_vsp_plane_reset,
> +	.atomic_create_state = rzg2l_du_vsp_plane_create_state,
>  	.atomic_duplicate_state = rzg2l_du_vsp_plane_atomic_duplicate_state,
>  	.atomic_destroy_state = rzg2l_du_vsp_plane_atomic_destroy_state,
>  };

[Severity: High]
This isn't a bug introduced by this patch, but while reviewing this file I
noticed a pre-existing issue in rzg2l_du_vsp_get_drm_plane():

drivers/gpu/drm/renesas/rz-du/rzg2l_du_vsp.c:rzg2l_du_vsp_get_drm_plane() {
	...
	struct drm_plane *plane = NULL;

	drm_for_each_plane(plane, &rcdu->ddev) {
		struct rzg2l_du_vsp_plane *vsp_plane = to_rzg2l_vsp_plane(plane);

		if (vsp_plane->index == pipe_index)
			break;
	}

	return plane ? plane : ERR_PTR(-EINVAL);
}

Is it possible for drm_for_each_plane() to finish without finding a match?

Since drm_for_each_plane() is a wrapper around list_for_each_entry(), the loop
iterator "plane" is not set to NULL when the list is exhausted. If no match
is found (e.g., if vsp_plane->index == pipe_index is never true), the loop
terminates without a break, leaving "plane" containing an invalid pointer
derived from the list head offset.

The ternary check "plane ? plane : ERR_PTR(-EINVAL)" will then evaluate to
true and return this invalid pointer instead of the error. This invalid pointer
could then be dereferenced during initialization on the error path by
drmm_crtc_init_with_planes(), leading to memory corruption or a kernel crash.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260831-drm-no-more-plane-reset-v3-0-1877c7aa57b3@kernel.org?part=35

  reply	other threads:[~2026-08-31 22:39 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 16:17 [PATCH v3 00/40] drm/plane: Convert all drivers to atomic_create_state and remove reset Maxime Ripard
2026-08-31 16:17 ` Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 01/40] drm/simple-kms: Remove unused reset_plane hook Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 02/40] drm/vkms: Convert to atomic_create_state Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 03/40] drm/gem-atomic-helper: Remove __drm_gem_reset_shadow_plane() Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 04/40] drm/amdgpu: Convert to atomic_create_state Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 05/40] drm/fsl-dcu: " Maxime Ripard
2026-08-31 19:22   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 06/40] drm/hisilicon/kirin: " Maxime Ripard
2026-08-31 18:07   ` John Stultz
2026-08-31 19:31   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 07/40] drm/imx/dc: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 08/40] drm/kmb: " Maxime Ripard
2026-08-31 19:44   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 09/40] drm/logicvc: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 10/40] drm/loongson: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 11/40] drm/lcdif: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 12/40] drm/mxsfb: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 13/40] drm/qxl: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 14/40] drm/rockchip: " Maxime Ripard
2026-08-31 16:17   ` Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 15/40] drm/sprd: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 16/40] drm/sti: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 17/40] drm/stm: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 18/40] drm/tests: kunit: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 19/40] drm/tilcdc: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 20/40] drm/vboxvideo: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 21/40] drm/verisilicon: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 22/40] drm/virtio: " Maxime Ripard
2026-08-31 21:16   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 23/40] drm/xlnx: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 24/40] drm/atomic-state-helper: Remove drm_atomic_helper_plane_reset() Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 25/40] drm/amdgpu_dm: Convert to atomic_create_state Maxime Ripard
2026-08-31 21:37   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 26/40] drm/armada: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 27/40] drm/atmel-hlcdc: Drop spurious csc_init call from reset Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 28/40] drm/atmel-hlcdc: Convert to atomic_create_state Maxime Ripard
2026-08-31 21:56   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 29/40] drm/exynos: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 30/40] drm/imx/ipuv3: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 31/40] drm/mediatek: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 32/40] drm/nouveau: " Maxime Ripard
2026-08-31 16:17   ` Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 33/40] drm/omap: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 34/40] drm/rcar-du: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 35/40] drm/rz-du: " Maxime Ripard
2026-08-31 22:39   ` sashiko-bot [this message]
2026-08-31 16:17 ` [PATCH v3 36/40] drm/shmobile: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 37/40] drm/sun4i: layer: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 38/40] drm/vmwgfx: " Maxime Ripard
2026-08-31 17:47   ` Zack Rusin
2026-08-31 22:58   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 39/40] drm/atomic-state-helper: Remove __drm_atomic_helper_plane_reset() Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 40/40] drm/plane: Remove reset Maxime Ripard

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=20260831223936.049AE1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mripard@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.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.