From: sashiko-bot@kernel.org
To: "Maxime Ripard" <mripard@kernel.org>
Cc: linux-sunxi@lists.linux.dev
Subject: Re: [PATCH v4 15/20] drm/connector: Add new atomic_create_state callback
Date: Thu, 14 May 2026 00:45:34 +0000 [thread overview]
Message-ID: <20260514004534.989F2C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260512-drm-mode-config-init-v4-15-591dfdcc1bf9@kernel.org>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Critical] Missing fallback to `atomic_create_state` in explicit `reset()` callers causes kernel panics (e.g., in `drmm_connector_hdmi_init`).
- [High] TV connector reset helpers are structurally incompatible with `atomic_create_state`, preventing driver migration.
- [High] Missing NULL check for `atomic_destroy_state` causes kernel panic on driver omission.
--
commit 9c7dcc4b2ba2f3c09ed3926c7e0db8c1a524dd31
Author: Maxime Ripard <mripard@kernel.org>
Subject: drm/connector: Add new atomic_create_state callback
This commit introduces the atomic_create_state callback for drm_connectors.
It allows drivers to allocate a pristine state without side-effects, separating
initialization from hardware reset operations during suspend and resume.
> diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
> index e2e5a1b8a8202..07686e94aae00 100644
> --- a/drivers/gpu/drm/drm_atomic_state_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_state_helper.c
[ ... ]
> @@ -534,6 +534,32 @@ void drm_atomic_helper_connector_reset(struct drm_connector *connector)
> }
> EXPORT_SYMBOL(drm_atomic_helper_connector_reset);
>
> +/**
> + * drm_atomic_helper_connector_create_state - default &drm_connector_funcs.atomic_create_state hook for connectors
> + * @connector: connector object
> + *
> + * Allocates and initializes pristine @drm_connector_state.
> + *
> + * This is useful for drivers that don't subclass @drm_connector_state.
> + *
> + * RETURNS:
> + * Pointer to new connector state, or ERR_PTR on failure.
> + */
> +struct drm_connector_state *
> +drm_atomic_helper_connector_create_state(struct drm_connector *connector)
> +{
> + struct drm_connector_state *state;
> +
> + state = kzalloc_obj(*state);
> + if (!state)
> + return ERR_PTR(-ENOMEM);
> +
> + __drm_atomic_helper_connector_state_init(state, connector);
> +
> + return state;
> +}
How should TV drivers migrating to atomic_create_state handle initialization?
The new pattern requires drivers to allocate and return a pristine state
without assigning it to connector->state. However, existing initialization
helpers like drm_atomic_helper_connector_tv_reset() and
drm_atomic_helper_connector_tv_margins_reset() are hardcoded to read and
modify connector->state directly.
If a TV driver attempts to use these helpers on its newly allocated state,
will the helpers dereference a NULL or stale connector->state and crash?
Would it make sense to introduce state-based variants of these helpers
that take a struct drm_connector_state pointer?
> +EXPORT_SYMBOL(drm_atomic_helper_connector_create_state);
[ ... ]
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 2e2cd18a14b43..9d240817f8b64 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
[ ... ]
> +static int drm_mode_config_connector_reset_with_create_state(struct drm_connector *connector)
> +{
> + if (connector->state) {
> + connector->funcs->atomic_destroy_state(connector, connector->state);
Is there a risk of a NULL pointer dereference here if a driver migrating to
atomic_create_state omits the atomic_destroy_state hook?
While omitting the hook is a driver bug, other DRM core functions like
drm_connector_cleanup() gracefully guard against this by checking
if (connector->funcs->atomic_destroy_state) before calling it. Should this
wrapper include a similar defensive guard to prevent system crashes?
> + connector->state = NULL;
> + }
> +
> + return drm_mode_config_connector_create_state(connector);
> +}
[ ... ]
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index 5ad62c207d009..529755c2e8620 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
[ ... ]
> @@ -1571,6 +1571,22 @@ struct drm_connector_funcs {
> */
> void (*destroy)(struct drm_connector *connector);
>
> + /**
> + * @atomic_create_state:
> + *
> + * Allocate a pristine, initialized, state for the connector
Does the introduction of atomic_create_state require updates to other core
functions that explicitly call the reset callback to allocate state?
For example, drmm_connector_hdmi_init() checks for connector->funcs->reset
and calls it. If a driver uses atomic_create_state instead, the reset check
fails and the state is never allocated.
Immediately after, drmm_connector_hdmi_init() calls
drm_connector_attach_max_bpc_property(), which dereferences the uninitialized
connector->state. Can this cause a kernel panic on boot for drivers migrating
to atomic_create_state?
> + * object and return it. This callback must have no side
> + * effects: in particular, the returned state must not be
> + * assigned to the object's state pointer and it must not affect
> + * the hardware state.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260512-drm-mode-config-init-v4-0-591dfdcc1bf9@kernel.org?part=15
next prev parent reply other threads:[~2026-05-14 0:45 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 13:05 [PATCH v4 00/20] drm/atomic: Rework initial state allocation Maxime Ripard
2026-05-12 13:05 ` [PATCH v4 01/20] drm/atomic: Document atomic commit lifetime Maxime Ripard
2026-05-13 21:25 ` sashiko-bot
2026-05-12 13:06 ` [PATCH v4 02/20] drm/colorop: Fix typos in the doc Maxime Ripard
2026-05-12 13:06 ` [PATCH v4 03/20] drm/atomic: Drop drm_private_obj.state assignment from create_state Maxime Ripard
2026-05-12 13:06 ` [PATCH v4 04/20] drm/atomic: Expand atomic_create_state expectations for drm_private_obj Maxime Ripard
2026-05-12 13:06 ` [PATCH v4 05/20] drm/mode-config: Document drm_private_obj exclusion from drm_mode_config_reset() Maxime Ripard
2026-05-12 13:06 ` [PATCH v4 06/20] drm/colorop: Rename __drm_colorop_state_reset() Maxime Ripard
2026-05-12 13:06 ` [PATCH v4 07/20] drm/colorop: Create drm_atomic_helper_colorop_create_state() Maxime Ripard
2026-05-13 22:50 ` sashiko-bot
2026-05-12 13:06 ` [PATCH v4 08/20] drm/atomic-state-helper: Fix __drm_atomic_helper_plane_reset() doc typo Maxime Ripard
2026-05-12 13:06 ` [PATCH v4 09/20] drm/atomic-state-helper: Rename __drm_atomic_helper_plane_state_reset() Maxime Ripard
2026-05-12 13:06 ` [PATCH v4 10/20] drm/plane: Add new atomic_create_state callback Maxime Ripard
2026-05-12 13:06 ` [PATCH v4 11/20] drm/atomic-state-helper: Rename __drm_atomic_helper_crtc_state_reset() Maxime Ripard
2026-05-12 13:06 ` [PATCH v4 12/20] drm/crtc: Add new atomic_create_state callback Maxime Ripard
2026-05-14 0:03 ` sashiko-bot
2026-05-12 13:06 ` [PATCH v4 13/20] drm/atomic-state-helper: Rename __drm_atomic_helper_connector_state_reset() Maxime Ripard
2026-05-12 13:06 ` [PATCH v4 14/20] drm/hdmi: Rename __drm_atomic_helper_connector_hdmi_reset() Maxime Ripard
2026-05-14 0:22 ` sashiko-bot
2026-05-12 13:06 ` [PATCH v4 15/20] drm/connector: Add new atomic_create_state callback Maxime Ripard
2026-05-14 0:45 ` sashiko-bot [this message]
2026-05-12 13:06 ` [PATCH v4 16/20] drm/mode-config: Create drm_mode_config_create_initial_state() Maxime Ripard
2026-05-14 0:57 ` sashiko-bot
2026-05-12 13:06 ` [PATCH v4 17/20] drm/drv: Switch skeleton to drm_mode_config_create_initial_state() Maxime Ripard
2026-05-12 13:06 ` [PATCH v4 18/20] drm/tidss: Switch " Maxime Ripard
2026-05-14 1:25 ` sashiko-bot
2026-05-12 13:06 ` [PATCH v4 19/20] drm/tidss: Convert to atomic_create_state Maxime Ripard
2026-05-12 13:06 ` [PATCH v4 20/20] drm/bridge_connector: " Maxime Ripard
2026-05-14 2:48 ` sashiko-bot
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=20260514004534.989F2C19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=mripard@kernel.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