From nobody Mon Feb 9 09:52:00 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3556C77B7F for ; Fri, 12 May 2023 11:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241059AbjELLPf (ORCPT ); Fri, 12 May 2023 07:15:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241028AbjELLPd (ORCPT ); Fri, 12 May 2023 07:15:33 -0400 Received: from exchange.fintech.ru (e10edge.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71C5E1720 for ; Fri, 12 May 2023 04:15:30 -0700 (PDT) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Fri, 12 May 2023 14:15:28 +0300 Received: from KANASHIN1.fintech.ru (10.0.253.125) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Fri, 12 May 2023 14:15:28 +0300 From: Natalia Petrova To: Ben Skeggs CC: Natalia Petrova , Karol Herbst , Lyude Paul , David Airlie , "Daniel Vetter" , , , , Subject: [PATCH] drm/nouveau/dp: check for NULL nv_connector->native_mode Date: Fri, 12 May 2023 14:15:26 +0300 Message-ID: <20230512111526.82408-1-n.petrova@fintech.ru> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.0.253.125] X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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: d4c2c99bdc83 ("drm/nouveau/dp: remove broken display depth function,= use the improved one") Signed-off-by: Natalia Petrova Reviewed-by: Lyude Paul --- drivers/gpu/drm/nouveau/nouveau_connector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/= nouveau/nouveau_connector.c index 086b66b60d91..5dbf025e6873 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -966,7 +966,7 @@ nouveau_connector_get_modes(struct drm_connector *conne= ctor) /* Determine display colour depth for everything except LVDS now, * DP requires this before mode_valid() is called. */ - if (connector->connector_type !=3D DRM_MODE_CONNECTOR_LVDS) + if (connector->connector_type !=3D DRM_MODE_CONNECTOR_LVDS && nv_connecto= r->native_mode) nouveau_connector_detect_depth(connector); =20 /* 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 *conne= ctor) * "native" mode as some VBIOS tables require us to use the * pixel clock as part of the lookup... */ - if (connector->connector_type =3D=3D DRM_MODE_CONNECTOR_LVDS) + if (connector->connector_type =3D=3D DRM_MODE_CONNECTOR_LVDS && nv_connec= tor->native_mode) nouveau_connector_detect_depth(connector); =20 if (nv_encoder->dcb->type =3D=3D DCB_OUTPUT_TV) --=20 2.34.1