From: Ian Rogers <irogers@google.com>
To: Lyude Paul <lyude@redhat.com>, Danilo Krummrich <dakr@kernel.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: Lyude Paul <lyude.paul@maintainer.cc>,
dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
Elkin Cruz <elkin@google.com>, Ian Rogers <irogers@google.com>
Subject: [PATCH v2 2/3] drm/nouveau: Fix error cleanup in nouveau_connector_create() default case
Date: Thu, 3 Dec 2026 09:27:41 -0800 [thread overview]
Message-ID: <20261203172742.470932-3-irogers@google.com> (raw)
In-Reply-To: <20261203172742.470932-1-irogers@google.com>
In nouveau_connector_create(), the default branch of the connector-type
switch returns NULL without destroying nv_connector->conn or freeing
nv_connector. Both callers (nv50_display_create() and
nv04_display_create()) only check IS_ERR(connector) and immediately
dereference connector on a NULL return.
Clean up nv_connector->conn and free nv_connector before returning
ERR_PTR(-EINVAL).
Found by code inspection while reviewing Clang's -Wswitch-enum warning
in nouveau_connector_create(); Gemini helped draft the patch and commit
message. Compile-tested on nouveau_connector.o with LLVM=1 W=1
(-Werror); not runtime-tested on NVIDIA GPU hardware.
Fixes: 8b7d92cad953 ("drm/nouveau/kms/nv50-: create connectors based on nvkm info")
Signed-off-by: Ian Rogers <irogers@google.com>
---
Notes:
v2:
- Split out from v1 patch 1/2 (Lyude Paul).
v1: https://lore.kernel.org/r/f0db7ca640d19d1021b4031b08be426532425095.1795106937.git.irogers@google.com
drivers/gpu/drm/nouveau/nouveau_connector.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index d71a920f0a3d..1e2ce2b46ad4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -1404,7 +1404,9 @@ nouveau_connector_create(struct drm_device *dev, int index)
case NVIF_CONN_HDMI : type = DCB_CONNECTOR_HDMI_0; break;
default:
WARN_ON(1);
- return NULL;
+ nvif_conn_dtor(&nv_connector->conn);
+ kfree(nv_connector);
+ return ERR_PTR(-EINVAL);
}
nv_connector->type = type;
--
2.56.1.911.g883d8bcb20-goog
next prev parent reply other threads:[~2026-12-03 17:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 17:27 [PATCH v2 0/3] drm/nouveau: Three fixes from Clang warning audit Ian Rogers
2026-12-03 17:27 ` [PATCH v2 1/3] drm/nouveau: Handle NVIF_CONN_TV in nouveau_connector_create() Ian Rogers
2026-12-03 17:27 ` Ian Rogers [this message]
2026-12-03 17:27 ` [PATCH v2 3/3] drm/nouveau/kms: Initialize primary_crc for RG CRC capture on GB20x Ian Rogers
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=20261203172742.470932-3-irogers@google.com \
--to=irogers@google.com \
--cc=airlied@gmail.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=elkin@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=lyude.paul@maintainer.cc \
--cc=lyude@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®