From: sashiko-bot@kernel.org
To: "Marek Czernohous" <mczernohous@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 2/2] drm/nouveau/kms: guard NULL crtc in nv50_sor_atomic_disable()
Date: Thu, 11 Jun 2026 07:39:01 +0000 [thread overview]
Message-ID: <20260611073901.9009D1F00893@smtp.kernel.org> (raw)
In-Reply-To: <66ea307dd4fa080db27b2b9a0caa31b562d72c2b.1781162589.git.marek@czernohous.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The early return added to guard against a NULL `nv_encoder->crtc` during inconsistent atomic disables is placed too late. When `CONFIG_DRM_NOUVEAU_BACKLIGHT` is enabled, the code unconditionally initializes and dereferences `nv_connector` (via `nv_connector->backlight`) before the new `!nv_encoder->crtc` safeguard is reached. In the exact state-tracking inconsistencies this patch aims to fix (e.g., disable without a matching enable), `nv50_outp_get_old_connector()` can return NULL, leading to a NULL pointer dereference.
--
commit c0ee57413f11f85e156ca80153f2707e59b79de5
Author: Marek Czernohous <mczernohous@gmail.com>
drm/nouveau/kms: guard NULL crtc in nv50_sor_atomic_disable()
This commit restores a NULL guard for the crtc pointer in
nv50_sor_atomic_disable() to prevent a kernel oops during VT switches and
Wayland session teardowns. The guard replaces a silent return with a warning
to ensure state-tracking inconsistencies remain visible without crashing.
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> index 6c3a8712d38ab..597bc64073a5c 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> @@ -1565,14 +1565,28 @@ static void
> nv50_sor_atomic_disable(struct drm_encoder *encoder, struct drm_atomic_state *state)
> {
> struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
> - struct nv50_head *head = nv50_head(nv_encoder->crtc);
> + struct nv50_head *head;
> #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
> struct nouveau_connector *nv_connector = nv50_outp_get_old_connector(state, nv_encoder);
> struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
> struct nouveau_backlight *backlight = nv_connector->backlight;
> struct drm_dp_aux *aux = &nv_connector->aux;
[Severity: High]
This isn't a bug introduced by this patch, but does the new early return
happen too late if CONFIG_DRM_NOUVEAU_BACKLIGHT is enabled?
In the exact disable-without-enable scenario this patch is addressing,
nv50_outp_get_old_connector() can return NULL. Because nv_connector is
unconditionally dereferenced here to initialize the backlight and aux
variables, won't this still cause a NULL pointer dereference in
nv50_sor_atomic_disable() before the newly added crtc guard is ever reached?
> int ret;
> +#endif
> +
> + /* nv_encoder->crtc is the driver's shadow pointer, set in
> + * .atomic_enable and cleared at the end of this function. NULL here
> + * means disable-without-enable or a double disable; bail before
> + * container_of() turns it into a bogus head pointer (checking the
> + * result would not work, container_of(NULL) is never NULL). The
> + * encoder release is handled by the commit_tail release loop, so
> + * there is nothing to clean up here.
> + */
> + if (drm_WARN_ON_ONCE(encoder->dev, !nv_encoder->crtc))
> + return;
> + head = nv50_head(nv_encoder->crtc);
>
> +#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
> if (backlight && backlight->uses_dpcd) {
> ret = drm_edp_backlight_disable(aux, &backlight->edp_info);
> if (ret < 0)
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1781162589.git.marek@czernohous.de?part=2
prev parent reply other threads:[~2026-06-11 7:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 7:26 [PATCH v2 0/2] drm/nouveau: NVAC (MCP79) MSI rearm + SOR-disable NULL guard Marek Czernohous
2026-06-11 7:26 ` [PATCH v2 1/2] drm/nouveau/pci: use config-space MSI rearm on MCP79/MCP7A (NVAC) Marek Czernohous
2026-06-11 7:26 ` [PATCH v2 2/2] drm/nouveau/kms: guard NULL crtc in nv50_sor_atomic_disable() Marek Czernohous
2026-06-11 7:39 ` 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=20260611073901.9009D1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=mczernohous@gmail.com \
--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 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.