Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10136734rwr; Fri, 12 May 2023 04:29:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7nr9ezx0VLdqGTfRM62SZr3pCHiQCktz5ddon9zM7DqxFOmhn6mi30Cf7y4PC0h+e0cWlc X-Received: by 2002:a05:6a20:7fa3:b0:ef:f558:b76 with SMTP id d35-20020a056a207fa300b000eff5580b76mr30308033pzj.5.1683890952987; Fri, 12 May 2023 04:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683890952; cv=none; d=google.com; s=arc-20160816; b=eiucFotzuOhRN17UT9ICwOhrompU0W8BjATaw11cQ+rrRiKwh8LVIjeYwC4SF/ucjm ysgt5AVgrqEQDPNEWTLs8Hb6Ujo1V6KFILN5FTdaz8wPtwt3P2nmnYxhvdHLPP1RJ0C9 vbb2Ul8Vd9BvB28TVlH8kpmU9ZvAdVop4Cafg1+5O7SvBFNnab/2ZctA8uUL0FmEsc3F BP1AMpVmWgrRfjevpk9DJKAgwlDRMG5T68SDqThjgItFd/YW7UilPFeo/QniPONLxM4M Hz1gJ5gOeFT4UwyOTYQOFfKiEdf0YAEog3lT3NElMRB9ax0akrD9FJw+eOG0zZ6hw7G+ TXQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=iyl2pJcovbrW9P8J6PGCmb3I7QtDx69GcTCr37MITok=; b=X4LTQGMwxzOdclUw8MUeLK7T7qWb+uRbCn61Z9gXZlWeiYCUayMlbQ5zjLLb2xm1Uc HL+ES6zTRoKUCg+Y5icxJ+OG6HCwSGh7qzqPR9+yPExAP0ZmwN4eIaiLZbOgU+uTXHFC DPIbP7lb46ZNR5oyqDv5DUJ9cKO3kVmGKRNfdPQ4JJfrHYZKH439VtYNNXrAYzldivYJ piFmL8sLh8n34pwDCpfLuAo5q8fHTSgOh/nl3qtWamX3yVS6QTvX79KNCxirbls3DTGG qSnCUMgZfMNc68yIkgUKqWV13gOzcAmiYtXxGBvnzx28nSzEyyZ5oK0H9+Tfmv0XFbrT xeSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j20-20020a633c14000000b0051f8817a307si9694754pga.869.2023.05.12.04.28.58; Fri, 12 May 2023 04:29:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241053AbjELLPe (ORCPT + 99 others); Fri, 12 May 2023 07:15:34 -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: 7BIT Content-Type: text/plain; charset=US-ASCII 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) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 *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) -- 2.34.1