Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2387957lqp; Sun, 24 Mar 2024 17:12:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXylxdho/+P9AKMSuywVrcElKdiOMIvZkhBXbn4S6coFjmHaL4UY1kfa1R9Le58fH81FXfbDtGNuRvCWyfgSBpgYtp5f3KUc1MtHAgKNA== X-Google-Smtp-Source: AGHT+IGK6lqSf/VFmlQBdp/GsvOgCn/7nphgs7vyiP/TLT+h37Fwtuqjvdp1+WctCAB7uhSVUOZG X-Received: by 2002:a05:620a:8c4:b0:789:da81:8f2f with SMTP id z4-20020a05620a08c400b00789da818f2fmr5401098qkz.26.1711325544611; Sun, 24 Mar 2024 17:12:24 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i25-20020ae9ee19000000b0078a0366a2c9si4399235qkg.693.2024.03.24.17.12.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:12:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113335-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=UzhDlEPx; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-113335-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113335-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 56D7F1C22D14 for ; Mon, 25 Mar 2024 00:12:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9557F197555; Sun, 24 Mar 2024 22:42:17 +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="UzhDlEPx" 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 97D7A6D1AB; Sun, 24 Mar 2024 22:42:16 +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=1711320136; cv=none; b=rgUloBT2bzc6LBxPr0fJeZo8N66oYo3TKp44l1/hjs6AX/tEvNBvDaU45kZfHhfX0bXPPKgvqP1lrDMvsoP0p5k23DGsND1Xnm11ZJkgav1OZKbN46gweWVZTFy1sCp0a8AgwbVM2WA/s0XcZlpIBwtuZYNrs2+5zgMYkEUOb1g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320136; c=relaxed/simple; bh=AE78y5qGH6kGnE6uPJn7AzC5Sja71QGpBQCSPAruAfo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uUccQHdvdXXKHnIn+cqPlM5vNMIUfK6f0rmotWwZnFQESChNsrcC0+12dJSZpk8tXdKrp1lq3dO5q/ZUm71dnIejvFXo34BHhOSRwas6sr3EJi8Yr8u8SE2BZPn0YrBK3BedwsGB0XbrsMZzFtmpdUlZskHNAYJfS647iP5Kp+k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UzhDlEPx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69243C433A6; Sun, 24 Mar 2024 22:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320136; bh=AE78y5qGH6kGnE6uPJn7AzC5Sja71QGpBQCSPAruAfo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UzhDlEPxmo52JkcDlI900XwSL/3JmwuoAFkMS9nnND+vsS+w+4IPaPVLvluwAKswZ noyrh9cfpMt/cesNeU0YZ2kGr0d/OqMD3/NkbWDydM9oUCPN2VozdlfG9pwrv03Nsl CbU9SmdHOCEw7DXZSLbBDDZz5rhRRdB2wgLafQN4VSwruECEAbuTsR0Fl9pvKlE2Mb c4x0mKVb97mk+4RIAlu1czP9NPFWW6ziuHiU4wiHFsyORyA8CP7v/leEYkk7ZqujVW 3ma9MFF/8Z40Q7GUCKNCTo5n2U/+RL9twM8ZJACdaP1Kyek7H0MdVGQ0fLv8kpmjuz LhD/3DbdDL6sA== 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.8 444/715] drm/amd/display: Add 'replay' NULL check in 'edp_set_replay_allow_active()' Date: Sun, 24 Mar 2024 18:30:23 -0400 Message-ID: <20240324223455.1342824-445-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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 046d3e2054153..f1489f4a40c12 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 @@ -892,7 +892,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