Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2552216lqp; Mon, 25 Mar 2024 02:17:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWrOraVXnqeLi1ceEfrTefOJtP5EwTx1u9JQ3nUPKC1rbdhXdmSyYnRbFv26txh1jdgcR6I5XH1c61hP72yfTwBKoIC0IQCwkRtmiLC7g== X-Google-Smtp-Source: AGHT+IFedlGDmY4Hv3v9NVr2U+E/1cMsoF97ELg3D9zWHF+nI//JZFe+LKK2CuQBc1T27X9cKVRE X-Received: by 2002:a17:907:7ea1:b0:a49:dfe1:d5e with SMTP id qb33-20020a1709077ea100b00a49dfe10d5emr1894106ejc.57.1711358250416; Mon, 25 Mar 2024 02:17:30 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id oz37-20020a1709077da500b00a4752c296dasi1250049ejc.371.2024.03.25.02.17.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 02:17:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115702-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=t3Rj4L4Z; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-115702-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115702-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 am.mirrors.kernel.org (Postfix) with ESMTPS id B95C61F35131 for ; Mon, 25 Mar 2024 09:09:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B4A6C259978; Mon, 25 Mar 2024 02:54:43 +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="t3Rj4L4Z" 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 0233D21087B; Sun, 24 Mar 2024 23:08:18 +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=1711321699; cv=none; b=F21CFsv/HWrKk+2qMx2+j5u/f/VEH7mB/j8Nm28yd1rto9v/L1qSOCnDKU9CX05xuKmlAfI+Bc+qhVVQLPapm9Ec6r7jFD9mYSiX7Co1HCGbQGx4tE7j1MfeXiajerfNI/3bg/GE/4VOv40S9GbgA/8Z5KthbD5CWj5B6CC+jz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321699; c=relaxed/simple; bh=0robPL3ORU/kdT281CZW4S42KKfCnq5JV9Z1hIIsSwE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T6BKnkiD6YCNxY0KnruI05aWf77/RP/U3iOrXOvT8IYLISSBFW5h6uxX0LpnEJUZebl/Jz1DQBUp1eDSE3FWEtDQu596OnRP8LCfoqSHT4/6WWtNF55nseg8T1xcR67/UXMqGnDGWRApFpdsRxRcXh+tG6ctb+5UU/0m2UQ+mx8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t3Rj4L4Z; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC982C433B1; Sun, 24 Mar 2024 23:08:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711321697; bh=0robPL3ORU/kdT281CZW4S42KKfCnq5JV9Z1hIIsSwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t3Rj4L4Z30NccqUfgjbd3uBmKA2U7qwNORPu3SehzJLYYwEeMUWLclTNIMjuJaHAn 51SGphk42wvQ20xndge+cJuxBWCNZgVkQU/EY7nUFIl6ekcyIjGH7JY23XIPIMHhIl gWGLhs89IW3wrIoQu+XUt/8AQHemqMWDAyQIEts/aRbrG9P6P4nHUyQxE+Oceq9kSI V5VYcGGF2HpTR355LBkuOhDSW96ACJpaV16o9gtoTbbQlCCkZgTXNuTsMuscMpxF+g +QGRDMrHmVPe7H/0WF7t6yaz/gdC2XcaQDGZoR1aLqVg152DJ8kl1OKAIU+DOflGNr U+5pd5n6qEHSQ== 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.6 426/638] drm/amd/display: Add 'replay' NULL check in 'edp_set_replay_allow_active()' Date: Sun, 24 Mar 2024 18:57:43 -0400 Message-ID: <20240324230116.1348576-427-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324230116.1348576-1-sashal@kernel.org> References: <20240324230116.1348576-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 6f64aab18f07b..13104d000b9e0 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 @@ -882,7 +882,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