mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [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; 5+ 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] 5+ 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-12-01  0:04   ` lyude
  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; 5+ 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	[flat|nested] 5+ 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
  2026-12-01  0:06   ` Lyude Paul
  1 sibling, 1 reply; 5+ 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	[flat|nested] 5+ 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-12-01  0:04   ` lyude
  0 siblings, 0 replies; 5+ messages in thread
From: lyude @ 2026-12-01  0:04 UTC (permalink / raw)
  To: Ian Rogers, Danilo Krummrich, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, nouveau, linux-kernel, llvm, Elkin Cruz

On Thu, 2026-11-19 at 09:03 -0800, Ian Rogers wrote:
> 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;

Make sure that the formatting of patches that you send matches the
formatting of the lines around it

Also, this should be split into two patches.

>  		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;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] drm/nouveau/kms: Initialize primary_crc for RG CRC capture on GB20x
  2026-11-19 17:03 ` [PATCH 2/2] drm/nouveau/kms: Initialize primary_crc for RG CRC capture on GB20x Ian Rogers
@ 2026-12-01  0:06   ` Lyude Paul
  0 siblings, 0 replies; 5+ messages in thread
From: Lyude Paul @ 2026-12-01  0:06 UTC (permalink / raw)
  To: Ian Rogers, Danilo Krummrich, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, nouveau, linux-kernel, llvm, Elkin Cruz

Reviewed-by: Lyude Paul <lyude.paul@maintainer.cc>

On Thu, 2026-11-19 at 09:03 -0800, Ian Rogers wrote:
> 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;
>  	}
>  

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-01  0:07 UTC | newest]

Thread overview: 5+ 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-12-01  0:04   ` lyude
2026-11-19 17:03 ` [PATCH 2/2] drm/nouveau/kms: Initialize primary_crc for RG CRC capture on GB20x Ian Rogers
2026-12-01  0:06   ` Lyude Paul

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®