Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2483775lqp; Sun, 24 Mar 2024 22:58:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWgJaxjg6g4NJwsXYLyI8U1F41efq6QccNugNOPNISkqf0kVN77ovIQTqbzLUg6XzEEdYdl+VueMMHuwX8GuqT1+ev1bVkb69ci+32CEg== X-Google-Smtp-Source: AGHT+IGSHTN9JB2LVK/ttUCADALSi0E7viZktJYuo88YqDNowlS3L6jPHThOl/e1W4qFnZAS4rj2 X-Received: by 2002:a17:90a:6387:b0:29e:9ab:980b with SMTP id f7-20020a17090a638700b0029e09ab980bmr7499574pjj.2.1711346279998; Sun, 24 Mar 2024 22:57:59 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d25-20020a631d19000000b005e83c9ed17fsi7052674pgd.797.2024.03.24.22.57.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 22:57:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113864-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b="A5j/aqUS"; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-113864-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113864-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8008CB2E09F for ; Mon, 25 Mar 2024 05:27:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C2F1209315; Sun, 24 Mar 2024 23:06:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A5j/aqUS" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BC031DCCAD; Sun, 24 Mar 2024 22:55:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320912; cv=none; b=r3NLsc2oCjx9lr9bS7XrkJEbZd8YMpHtdBGyZroBdJK4vNyUpjqsGg2HVHxceFhEgz5/me6iJhZaC/KafVg2e509V1DYqrYadEWlke8L+Uk17LOBY23kjkCHIl/2mrMW40i4ej//Y6LF0jRJQQA4+e4Haty04hQi+9OZAaHZHRA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320912; c=relaxed/simple; bh=RG5DNBFWOVV6swYzwisXML9v67pmLM2qNfQPiK8Naw0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FvGXFN7f5Nbh0v7k/vBEKd0xy75L7aWOaP1OGK3gJD6lbpl9W/N5vn2hQaYF4iXAteS/0/Rejq4lHKJUsZLgUnPWGdfmD25xChYHy7z2PtYgxlidUtkWkjSefb4hRGdini+4SBQUdWSRPHfYpNerKavYqcEOs93r1/GIAkok0gw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A5j/aqUS; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9E0EC433F1; Sun, 24 Mar 2024 22:55:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320911; bh=RG5DNBFWOVV6swYzwisXML9v67pmLM2qNfQPiK8Naw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A5j/aqUSCXNAa7WeaykddcYjQGwW/y6jQ1oruo1AoBSfIHHVH0z8Svr3wTT7H/zMq H6W1AC48M0ZJb28TVTtZ8W4bOxzNkIuW7eC80W0MV6/g8MZDBjllZrWjLqMiQgXOvW 3+lHkRJsr5Drg0MLJDp36Jx+EbXjK9LBVyhbohrxLSYsiA+IFL/Wjv/1LIaIMLkQwM 636/nWXFtM0PHMcnXdMLquzI+BbqYVsa/aYEvwbBs7Nk+sToGwHNwJ1rwxqOI4/lPv J7WE/AqoL/WUJrnJE30aw/RwOjXAclFkrsxl+zzdAI48361UiHIdQrnZzXMoRrFSrK TvsnnuN8RIrRQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Srinivasan Shanmugam , Bhawanpreet Lakha , Roman Li , Rodrigo Siqueira , Aurabindo Pillai , Tom Chung , Alex Deucher , Sasha Levin Subject: [PATCH 6.7 474/713] drm/amd/display: Add 'replay' NULL check in 'edp_set_replay_allow_active()' Date: Sun, 24 Mar 2024 18:43:20 -0400 Message-ID: <20240324224720.1345309-475-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Srinivasan Shanmugam [ Upstream commit f6aed043ee5d75b3d1bfc452b1a9584b63c8f76b ] In the first if statement, we're checking if 'replay' is NULL. But in the second if statement, we're not checking if 'replay' is NULL again before calling replay->funcs->replay_set_power_opt(). if (replay == NULL && force_static) return false; .. if (link->replay_settings.replay_feature_enabled && replay->funcs->replay_set_power_opt) { replay->funcs->replay_set_power_opt(replay, *power_opts, panel_inst); link->replay_settings.replay_power_opt_active = *power_opts; } If 'replay' is NULL, this will cause a null pointer dereference. Fixes the below found by smatch: drivers/gpu/drm/amd/amdgpu/../display/dc/link/protocols/link_edp_panel_control.c:895 edp_set_replay_allow_active() error: we previously assumed 'replay' could be null (see line 887) Fixes: c7ddc0a800bc ("drm/amd/display: Add Functions to enable Freesync Panel Replay") Cc: Bhawanpreet Lakha Cc: Roman Li Cc: Rodrigo Siqueira Cc: Aurabindo Pillai Cc: Tom Chung Suggested-by: Tom Chung Signed-off-by: Srinivasan Shanmugam Reviewed-by: Tom Chung Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- .../drm/amd/display/dc/link/protocols/link_edp_panel_control.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c index bdae54c4648bc..7c4a93d3cda5d 100644 --- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c +++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c @@ -889,7 +889,8 @@ bool edp_set_replay_allow_active(struct dc_link *link, const bool *allow_active, /* Set power optimization flag */ if (power_opts && link->replay_settings.replay_power_opt_active != *power_opts) { - if (link->replay_settings.replay_feature_enabled && replay->funcs->replay_set_power_opt) { + if (replay != NULL && link->replay_settings.replay_feature_enabled && + replay->funcs->replay_set_power_opt) { replay->funcs->replay_set_power_opt(replay, *power_opts, panel_inst); link->replay_settings.replay_power_opt_active = *power_opts; } -- 2.43.0