ARM Sunxi Platform Development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maxime Ripard" <mripard@kernel.org>
Cc: dri-devel@lists.freedesktop.org, linux-sunxi@lists.linux.dev
Subject: Re: [PATCH 61/75] drm/sun4i: tv: Convert to atomic_create_state
Date: Wed, 14 Oct 2026 18:08:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-171662@kernel.org> (raw)
In-Reply-To: <20261014-drm-no-more-connector-reset-v1-61-586c9c026823@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm: NULL pointer dereference when initializing TV connector state
--

commit a85a6a0ad13c063d072cdcda87267ea8867cafa3
Author: Maxime Ripard <mripard@kernel.org>

drm/sun4i: tv: Convert to atomic_create_state

The sun4i TV connector reset implementation is converted to an
atomic_create_state hook. It creates the pristine state and initializes
the analog TV properties.

> diff --git a/drivers/gpu/drm/sun4i/sun4i_tv.c b/drivers/gpu/drm/sun4i/sun4i_tv.c
> index ea86f8a6a35e7..a68e5f7a03d2c 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_tv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_tv.c
[ ... ]
> -static void sun4i_tv_connector_reset(struct drm_connector *connector)
> +static struct drm_connector_state *
> +sun4i_tv_connector_create_state(struct drm_connector *connector)
>  {
> -	drm_atomic_helper_connector_reset(connector);
> -	drm_atomic_helper_connector_tv_state_init(connector->state, connector);
> +	struct drm_connector_state *connector_state;
> +
> +	connector_state = drm_atomic_helper_connector_create_state(connector);
> +	if (IS_ERR(connector_state))
> +		return connector_state;
> +
> +	drm_atomic_helper_connector_tv_state_init(connector_state, connector);

[Severity: High]
Does this trigger a NULL pointer dereference during initialization?

When the DRM core resets the connector state, it explicitly clears the old
state before invoking the .atomic_create_state hook:

drm_mode_config_connector_reset_with_create_state() {
        ...
        if (connector->state) {
                ...
                connector->state = NULL;
        }
        return drm_mode_config_connector_create_state(connector);
}

The core helper drm_atomic_helper_connector_tv_state_init() then mistakenly
passes the unassigned connector->state down to the margins initialization
instead of the newly allocated state:

drm_atomic_helper_connector_tv_state_init() {
        ...
        drm_atomic_helper_connector_tv_margins_state_init(connector->state,
                                                          connector);
}

This causes drm_atomic_helper_connector_tv_margins_state_init() to
unconditionally dereference the NULL state pointer:

drm_atomic_helper_connector_tv_margins_state_init(state, ...) {
        ...
        state->tv.margins.left = cmdline->tv_margins.left;
        ...
}

The previous .reset hook implementation masked this core helper bug because
it assigned connector->state prior to calling the TV state initialization
helper.

Could we fix the core helper to pass the correct state pointer, or should
this driver handle the initialization differently to avoid the crash?

> +
> +	return connector_state;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261014-drm-no-more-connector-reset-v1-0-586c9c026823@kernel.org?part=61

      reply	other threads:[~2026-10-14 18:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 17:26 [PATCH 00/75] drm/connector: Convert all drivers to atomic_create_state and remove reset Maxime Ripard
2026-10-14 17:27 ` [PATCH 38/75] drm/sun4i: Switch to drm_atomic_helper_connector_create_state Maxime Ripard
2026-10-14 17:27 ` [PATCH 56/75] drm/atomic-state-helper: Rename connector_tv_reset to state_init Maxime Ripard
2026-10-14 18:03   ` sashiko-bot
2026-10-14 17:27 ` [PATCH 60/75] drm/sun4i: hdmi: Convert to atomic_create_state Maxime Ripard
2026-10-14 17:27 ` [PATCH 61/75] drm/sun4i: tv: " Maxime Ripard
2026-10-14 18:08   ` sashiko-bot [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=sashiko-outbox-171662@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.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