Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2198028rwl; Mon, 26 Dec 2022 10:21:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXtUVQcTBr7TDxBEZZa7NMCkry3qpj6cwmN5getnxMM8JYgbaNLFv6vqL1prwFv0ETgkzVgX X-Received: by 2002:aa7:d589:0:b0:46c:d2f2:123d with SMTP id r9-20020aa7d589000000b0046cd2f2123dmr16758955edq.40.1672078882907; Mon, 26 Dec 2022 10:21:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672078882; cv=none; d=google.com; s=arc-20160816; b=e6Gz2jInwGzXYc3ceCSaiUm+p/a/riFS1E5VI4pIugarLSkRv3fcAMGfpCAyMoSCoh mBc5XdvR0/AWojh6oTc6XIoJ1U1qaA2+/zPrdAyHHzyflKD4L/thVTtwF7hjohKkiQaQ Vwu7XFIJ/jbavQiaG6cVfhpTDZpHHxDGczrVjTPUhXHh2vMOQbykz4H/DsZ6ixCBlUIl 9Nc9oUOlOMSxaksd/WdvFJopLkLt6K/iP4EzmuAXDCHSwsp9ZwZwQ+rLTjGLaCxcIWMo MsWr+lRyZKyEKG1CHWNKusLOK55WPp/WY7OgmBZHcGGfOhDWWOa80UhEidCtncXoaPNH ioxg== 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=AqDPoQWvbaQSGLfrVkqG7P++8l+M1le+ZTLpG7rbL+A=; b=LFOieVMU+jg707wXYakE0Gq/KBCtwtb5MMFwm7UdfWiViLxCpMtU2PZOCQ7r6FGI0V aJ3YbKMSQMqAJ7AIrARwOk0gj0lVhspvGmIT08PVzr1XdPKxObqgJSt5rMr/Q9ByEJNF IeniE95zCHIFLtH4IlfKBTj1qW0qQzTMq3T2orvyjvKhnU7MyIqXU7USTM8m05rHaf/O 5S+If1PHkNCr0+LlvIWB+i7KIbjeO8/lVdWdso6+PCMxYhWwRNNOSO96/3ZJDO3OCEYg nPzShTGyfaoJIAszsd45Ior5cXB40c2qLY4XM/mtSC3EWSLvIa1Bl29MPATAi4bncYGo ZTcQ== 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 v18-20020a056402349200b0047b405e7746si10018297edc.1.2022.12.26.10.21.07; Mon, 26 Dec 2022 10:21:22 -0800 (PST) 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 S232238AbiLZSMD (ORCPT + 66 others); Mon, 26 Dec 2022 13:12:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231422AbiLZSLk (ORCPT ); Mon, 26 Dec 2022 13:11:40 -0500 Received: from exchange.fintech.ru (e10edge.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C582218B for ; Mon, 26 Dec 2022 10:11:35 -0800 (PST) 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; Mon, 26 Dec 2022 21:10:28 +0300 Received: from localhost (10.0.253.157) 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; Mon, 26 Dec 2022 21:10:28 +0300 From: Nikita Zhandarovich To: Alex Deucher CC: Nikita Zhandarovich , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , Daniel Vetter , , , , Subject: [PATCH] drm/radeon: Fix potential null-ptr-deref Date: Mon, 26 Dec 2022 10:10:23 -0800 Message-ID: <20221226181023.86196-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.253.157] X-ClientProxiedBy: Ex16-01.fintech.ru (10.0.10.18) 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 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 radeon_get_connector_for_encoder() assigns radeon_encoder->enc_priv to mst_enc which is dereferenced later without being checked for NULL beforehand. It is possible for radeon_encoder->enc_priv and therefore mst_enc, to be NULL due to potential lack of memory. This patch adds a sanity NULL-check to prevent the issue. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 9843ead08f18 ("drm/radeon: add DisplayPort MST support (v2)") Signed-off-by: Nikita Zhandarovich --- drivers/gpu/drm/radeon/radeon_encoders.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c index 46549d5179ee..3f68f0af443a 100644 --- a/drivers/gpu/drm/radeon/radeon_encoders.c +++ b/drivers/gpu/drm/radeon/radeon_encoders.c @@ -251,6 +251,9 @@ radeon_get_connector_for_encoder(struct drm_encoder *encoder) continue; mst_enc = radeon_encoder->enc_priv; + if (!mst_enc) + return NULL; + if (mst_enc->connector == radeon_connector->mst_port) return connector; } else if (radeon_encoder->active_device & radeon_connector->devices) -- 2.25.1