Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2db30054 authored by Natalia Petrova's avatar Natalia Petrova Committed by Greg Kroah-Hartman
Browse files

drm/nouveau/dp: check for NULL nv_connector->native_mode



[ Upstream commit 20a2ce87fbaf81e4c3dcb631d738e423959eb320 ]

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.

Fixes: d4c2c99b ("drm/nouveau/dp: remove broken display depth function, use the improved one")

Signed-off-by: default avatarNatalia Petrova <n.petrova@fintech.ru>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230512111526.82408-1-n.petrova@fintech.ru


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent f6f2a554
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -916,7 +916,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
@@ -937,7 +937,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)