[PATCH v2 2/3] drm/nouveau: Fix error cleanup in nouveau_connector_create() default case
From: Ian Rogers
Date: Thu Dec 03 2026 - 12:28:29 EST
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@xxxxxxxxxx>
---
Notes:
v2:
- Split out from v1 patch 1/2 (Lyude Paul).
v1: https://lore.kernel.org/r/f0db7ca640d19d1021b4031b08be426532425095.1795106937.git.irogers@xxxxxxxxxx
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