drm/nouveau/dp: check for NULL nv_connector->native_mode
Subsystems (3)
PATCH 1/1 drm/nouveau/dp: check for NULL nv_connector->native_mode
Add checking for NULL before calling nouveau_connector_detect_depth() in nouveau_connector_get_modes() function because nv_connector->native_mode could be dereferenced there since connector pointer passed to nouveau_connector_detect_depth() and the same value of nv_connector->native_mode is used there.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/nouveau/nouveau_connector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_connector.c +2 -2
@@ -966,7 +966,7 @@ nouveau_connector_get_modes(struct drm_connector *connector)/* Determine display colour depth for everything except LVDS now, * DP requires this before mode_valid() is called. */ -if (connector->connector_type !=DRM_MODE_CONNECTOR_LVDS ) +if (connector->connector_type !=DRM_MODE_CONNECTOR_LVDS && nv_connector->native_mode)nouveau_connector_detect_depth (connector);/* Find the native mode if this is a digital panel, if we didn't
@@ -987,7 +987,7 @@ nouveau_connector_get_modes(struct drm_connector *connector)* "native" mode as some VBIOS tables require us to use the * pixel clock as part of the lookup... */ -if (connector->connector_type ==DRM_MODE_CONNECTOR_LVDS ) +if (connector->connector_type ==DRM_MODE_CONNECTOR_LVDS && nv_connector->native_mode)nouveau_connector_detect_depth (connector);if (nv_encoder->dcb->type ==DCB_OUTPUT_TV )
Signature · 1 line
2.34.1
Will push upstream in a bit
Quoted 37 lines · Natalia Petrova
Add checking for NULL before calling
nouveau_connector_detect_depth()innouveau_connector_get_modes()function becausenv_connector->native_modecould be dereferenced there since connector pointer passed tonouveau_connector_detect_depth()and the same value ofnv_connector->native_modeis used there.Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes d4c2c99bdc83 ("drm/nouveau/dp: remove broken display depth function, use the improved one")Signed-off-by Natalia Petrova <[email protected]>--- drivers/gpu/drm/nouveau/nouveau_connector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/nouveau/nouveau_connector.c +2
-2@@ -966,7 +966,7 @@ nouveau_connector_get_modes(struct drm_connector *connector)/* Determine display colour depth for everything except LVDS now, * DP requires this before mode_valid() is called. */ -if (connector->connector_type !=DRM_MODE_CONNECTOR_LVDS ) +if (connector->connector_type !=DRM_MODE_CONNECTOR_LVDS && nv_connector->native_mode)nouveau_connector_detect_depth (connector);/* Find the native mode if this is a digital panel, if we didn't @@ -987,7 +987,7 @@ nouveau_connector_get_modes(struct drm_connector *connector)* "native" mode as some VBIOS tables require us to use the * pixel clock as part of the lookup... */ -if (connector->connector_type ==DRM_MODE_CONNECTOR_LVDS ) +if (connector->connector_type ==DRM_MODE_CONNECTOR_LVDS && nv_connector->native_mode)nouveau_connector_detect_depth (connector);if (nv_encoder->dcb->type ==DCB_OUTPUT_TV )
Signature · 3 lines
Cheers, Lyude Paul (she/her) Software Engineer at Red Hat