* [PATCH 0/2] drm/nouveau: Two fixes from Clang warning audit
@ 2026-11-19 17:03 Ian Rogers
2026-11-19 17:03 ` [PATCH 1/2] drm/nouveau: Handle NVIF_CONN_TV and fix error cleanup in nouveau_connector_create() Ian Rogers
2026-11-19 17:03 ` [PATCH 2/2] drm/nouveau/kms: Initialize primary_crc for RG CRC capture on GB20x Ian Rogers
0 siblings, 2 replies; 4+ messages in thread
From: Ian Rogers @ 2026-11-19 17:03 UTC (permalink / raw)
To: Lyude Paul, Danilo Krummrich, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, nouveau, linux-kernel, llvm, Elkin Cruz, Ian Rogers
Two independent fixes in drm/nouveau found while auditing Clang
warnings (-Wswitch-enum and -Wconditional-uninitialized) on an
x86_64 allyesconfig build:
1. Handle NVIF_CONN_TV and release nv_connector on error in
nouveau_connector_create().
2. Initialize primary_crc before switching on src in
crcca7d_get_crc() for GB20x RG CRC capture.
Build-tested with LLVM=1 W=1 (-Werror); not runtime-tested on
Nouveau hardware.
Ian Rogers (2):
drm/nouveau: Handle NVIF_CONN_TV and fix error cleanup in
nouveau_connector_create()
drm/nouveau/kms: Initialize primary_crc for RG CRC capture on GB20x
drivers/gpu/drm/nouveau/dispnv50/crcca7d.c | 1 +
drivers/gpu/drm/nouveau/nouveau_connector.c | 7 ++++++-
2 files changed, 7 insertions(+), 1 deletion(-)
--
2.56.1.708.g77570a6a1d-goog
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/2] drm/nouveau: Handle NVIF_CONN_TV and fix error cleanup in nouveau_connector_create()
2026-11-19 17:03 [PATCH 0/2] drm/nouveau: Two fixes from Clang warning audit Ian Rogers
@ 2026-11-19 17:03 ` Ian Rogers
2026-11-19 17:13 ` sashiko-bot
2026-11-19 17:03 ` [PATCH 2/2] drm/nouveau/kms: Initialize primary_crc for RG CRC capture on GB20x Ian Rogers
1 sibling, 1 reply; 4+ messages in thread
From: Ian Rogers @ 2026-11-19 17:03 UTC (permalink / raw)
To: Lyude Paul, Danilo Krummrich, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, nouveau, linux-kernel, llvm, Elkin Cruz, Ian Rogers
In nouveau_connector_create(), the switch translating nvif connector
types (nv_connector->conn.info.type) to DCB connector types omits
NVIF_CONN_TV, even though nvkm_uconn_new() maps DCB TV connectors to
NVIF_CONN_V0_TV -> NVIF_CONN_TV and the rest of nouveau_connector.c
handles DCB_CONNECTOR_TV_0.
Furthermore, the default branch returns NULL without destroying
nv_connector->conn or freeing nv_connector, whereas both callers
(nv50_display_create() and nv04_display_create()) check only
IS_ERR(connector) and immediately dereference connector on NULL.
Map NVIF_CONN_TV to DCB_CONNECTOR_TV_0, and clean up nv_connector->conn
and nv_connector before returning ERR_PTR(-EINVAL) in the default
branch.
Found by enabling Clang's -Wswitch-enum on an x86_64 allyesconfig build,
with AI coding assistant help to audit the warning and prepare the fix.
Build-tested with Clang; 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>
---
drivers/gpu/drm/nouveau/nouveau_connector.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index cc3caf8de64b..51580824df36 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -1394,6 +1394,9 @@ nouveau_connector_create(struct drm_device *dev, int index)
switch (nv_connector->conn.info.type) {
case NVIF_CONN_VGA : type = DCB_CONNECTOR_VGA; break;
+ case NVIF_CONN_TV:
+ type = DCB_CONNECTOR_TV_0;
+ break;
case NVIF_CONN_DVI_I : type = DCB_CONNECTOR_DVI_I; break;
case NVIF_CONN_DVI_D : type = DCB_CONNECTOR_DVI_D; break;
case NVIF_CONN_LVDS : type = DCB_CONNECTOR_LVDS; break;
@@ -1403,7 +1406,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.708.g77570a6a1d-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] drm/nouveau: Handle NVIF_CONN_TV and fix error cleanup in nouveau_connector_create()
2026-11-19 17:03 ` [PATCH 1/2] drm/nouveau: Handle NVIF_CONN_TV and fix error cleanup in nouveau_connector_create() Ian Rogers
@ 2026-11-19 17:13 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-19 17:13 UTC (permalink / raw)
To: Ian Rogers; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/nouveau: missing drm_connector_cleanup() in
nouveau_connector_create() [1]
--
commit 35127d593c69f43f2dbfc8d677382d137440fa37
Author: Ian Rogers <irogers@google.com>
drm/nouveau: Handle NVIF_CONN_TV and fix error cleanup in nouveau_connector_create()
This commit maps NVIF_CONN_TV to DCB_CONNECTOR_TV_0 in
nouveau_connector_create() and cleans up nv_connector->conn and
nv_connector before returning ERR_PTR(-EINVAL) in the default switch case.
> diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
> index e472c23c29811..22545fd06e05b 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_connector.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
> @@ -1437,6 +1437,9 @@ nouveau_connector_create(struct drm_device *dev, int index)
>
> switch (nv_connector->conn.info.type) {
> case NVIF_CONN_VGA : type = DCB_CONNECTOR_VGA; break;
> + case NVIF_CONN_TV:
> + type = DCB_CONNECTOR_TV_0;
> + break;
> case NVIF_CONN_DVI_I : type = DCB_CONNECTOR_DVI_I; break;
> case NVIF_CONN_DVI_D : type = DCB_CONNECTOR_DVI_D; break;
> case NVIF_CONN_LVDS : type = DCB_CONNECTOR_LVDS; break;
> @@ -1446,7 +1449,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;
[Severity: High]
This problem wasn't introduced by this patch, but later in
nouveau_connector_create(), does the LVDS error path [1] free
nv_connector without calling drm_connector_cleanup()?
drivers/gpu/drm/nouveau/nouveau_connector.c:nouveau_connector_create() {
...
drm_connector_init(dev, connector, funcs, type);
switch (type) {
case DRM_MODE_CONNECTOR_LVDS:
ret = nouveau_bios_parse_lvds_table(dev, 0, &dummy, &dummy);
if (ret) {
NV_ERROR(drm, "Error parsing LVDS table, disabling\n");
kfree(nv_connector);
return ERR_PTR(ret);
}
...
}
If nouveau_bios_parse_lvds_table() fails after drm_connector_init() has
registered connector with the DRM core, calling kfree(nv_connector)
directly leaks the connector IDA and leaves a dangling pointer on the DRM
connector list, causing a use-after-free when the list is later traversed
or torn down.
[1] https://sashiko.dev/#/bug/linux-5fc9af31-e33a-4535-9e9a-4dc95a2d84c3
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795106937.git.irogers@google.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] drm/nouveau/kms: Initialize primary_crc for RG CRC capture on GB20x
2026-11-19 17:03 [PATCH 0/2] drm/nouveau: Two fixes from Clang warning audit Ian Rogers
2026-11-19 17:03 ` [PATCH 1/2] drm/nouveau: Handle NVIF_CONN_TV and fix error cleanup in nouveau_connector_create() Ian Rogers
@ 2026-11-19 17:03 ` Ian Rogers
1 sibling, 0 replies; 4+ messages in thread
From: Ian Rogers @ 2026-11-19 17:03 UTC (permalink / raw)
To: Lyude Paul, Danilo Krummrich, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, nouveau, linux-kernel, llvm, Elkin Cruz, Ian Rogers
In crcca7d_set_src(), selecting the "rg" CRC source passes
NV50_CRC_SOURCE_TYPE_RG, hitting the default case without initializing
primary_crc before packing it into HEAD_SET_CRC_CONTROL's PRIMARY_CRC
field.
Initialize primary_crc to NVCA7D_HEAD_SET_CRC_CONTROL_PRIMARY_CRC_NONE
in the default branch, matching crcc37d_set_src() where RG CRC capture
leaves PRIMARY_CRC set to NONE.
Found via Clang -Wconditional-uninitialized on an x86_64 allyesconfig
build. Verified by building drivers/gpu/drm/nouveau/dispnv50/crcca7d.o
with LLVM=1 W=1 (-Werror) and -Wconditional-uninitialized; not
runtime-tested on NVIDIA Blackwell (GB20x) hardware.
Fixes: 6cc6e08d4542 ("drm/nouveau/kms: add support for GB20x")
Signed-off-by: Ian Rogers <irogers@google.com>
---
drivers/gpu/drm/nouveau/dispnv50/crcca7d.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/nouveau/dispnv50/crcca7d.c b/drivers/gpu/drm/nouveau/dispnv50/crcca7d.c
index 912f59aebe87..02db81e5c8a3 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/crcca7d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/crcca7d.c
@@ -65,6 +65,7 @@ crcca7d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source
primary_crc = NVCA7D_HEAD_SET_CRC_CONTROL_PRIMARY_CRC_SF;
break;
default:
+ primary_crc = NVCA7D_HEAD_SET_CRC_CONTROL_PRIMARY_CRC_NONE;
break;
}
--
2.56.1.708.g77570a6a1d-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-19 17:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 17:03 [PATCH 0/2] drm/nouveau: Two fixes from Clang warning audit Ian Rogers
2026-11-19 17:03 ` [PATCH 1/2] drm/nouveau: Handle NVIF_CONN_TV and fix error cleanup in nouveau_connector_create() Ian Rogers
2026-11-19 17:13 ` sashiko-bot
2026-11-19 17:03 ` [PATCH 2/2] drm/nouveau/kms: Initialize primary_crc for RG CRC capture on GB20x Ian Rogers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox