Skip to contentSkip to conversation

nouveau_connector: add nv_encoder pointer check for NULL

PATCH In review Natalia Petrova 2 participants 2 messages May 12, 2023 – Jun 13, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nouveau_connector: add nv_encoder pointer check for NULL

Pointer nv_encoder could be dereferenced at nouveau_connector.c in case it's equal to NULL by jumping to goto label. This patch adds a NULL-check to avoid it.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 3195c5f9784a ("drm/nouveau: set encoder for lvds")
---
 drivers/gpu/drm/nouveau/nouveau_connector.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_connector.c +2 -1
index 43a9d1e1cf71..90ba6d0a9c80 100644
@@ -729,7 +729,8 @@ nouveau_connector_detect_lvds(struct drm_connector *connector, bool force)
 #endif
 
 	nouveau_connector_set_edid(nv_connector, edid);
-	nouveau_connector_set_encoder(connector, nv_encoder);
+	if (nv_encoder)
+		nouveau_connector_set_encoder(connector, nv_encoder);
 	return status;
 }
 
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Nice catch!

Will push upstream

Quoted 26 lines · Natalia Petrova

Pointer nv_encoder could be dereferenced at nouveau_connector.c in case it's equal to NULL by jumping to goto label. This patch adds a NULL-check to avoid it.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 3195c5f9784a ("drm/nouveau: set encoder for lvds")
---
 drivers/gpu/drm/nouveau/nouveau_connector.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_connector.c +2 -1
index 43a9d1e1cf71..90ba6d0a9c80 100644
@@ -729,7 +729,8 @@ nouveau_connector_detect_lvds(struct drm_connector *connector, bool force)
 #endif
 
 	nouveau_connector_set_edid(nv_connector, edid);
-	nouveau_connector_set_encoder(connector, nv_encoder);
+	if (nv_encoder)
+		nouveau_connector_set_encoder(connector, nv_encoder);
 	return status;
 }
 
Signature · 3 lines
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat