From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA27BC3601A for ; Thu, 3 Apr 2025 19:13:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2BA9210EA7D; Thu, 3 Apr 2025 19:13:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="L/AKLBv0"; dkim-atps=neutral Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7F36E10EA7B; Thu, 3 Apr 2025 19:13:42 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id CE60F434E9; Thu, 3 Apr 2025 19:13:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A5A3C4CEE3; Thu, 3 Apr 2025 19:13:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743707622; bh=eWgw06fRSvqjEvBo5bsP/T6Y4MFBKn6dv3hWxJrlJ1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L/AKLBv0gsxasLR1JAdK5poTbGXD0W3wW3laj7gwOzSEXh0Ts5ZLuDZiygtKEStEw u+ip4yGFqFOU+44KRE7hTs6cWUTT/ANyC8pJHpJubaxJP5ycyp/9sVDY08cq2r6Xg4 g2rW4mxT/DgMkFl70Jr74ljy3qd8B6aOEuvgEsj+JFPCoZ3f78ALPTIH2iAwKouc+d X6ra8J8xq+Z0FEgzQfjB3Z84P9v3hqk6srNXpxyo76y8xo6MKprNhxRq4+f57LWTG1 JWpbQDt7V3W90BUn9z878PS7BRoTQC8JU2C7h/DvDTTHyNObxGDQRaO1IBUIa+l3At tq1vaPeQWhEAQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sung Lee , Joshua Aberback , Zaeem Mohamed , Daniel Wheeler , Alex Deucher , Sasha Levin , harry.wentland@amd.com, sunpeng.li@amd.com, christian.koenig@amd.com, airlied@gmail.com, simona@ffwll.ch, siqueira@igalia.com, alvin.lee2@amd.com, alex.hung@amd.com, Wayne.Lin@amd.com, Austin.Zheng@amd.com, Ilya.Bakoulin@amd.com, aurabindo.pillai@amd.com, mario.limonciello@amd.com, Josip.Pavic@amd.com, dillon.varone@amd.com, wenjing.liu@amd.com, linux@treblig.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.14 09/44] drm/amd/display: Guard Possible Null Pointer Dereference Date: Thu, 3 Apr 2025 15:12:38 -0400 Message-Id: <20250403191313.2679091-9-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250403191313.2679091-1-sashal@kernel.org> References: <20250403191313.2679091-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.14 Content-Transfer-Encoding: 8bit X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" From: Sung Lee [ Upstream commit c87d202692de34ee71d1fd4679a549a29095658a ] [WHY] In some situations, dc->res_pool may be null. [HOW] Check if pointer is null before dereference. Reviewed-by: Joshua Aberback Signed-off-by: Sung Lee Signed-off-by: Zaeem Mohamed Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/dc/core/dc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index f84e795e35f58..4683c7ef4507f 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -5549,9 +5549,11 @@ void dc_allow_idle_optimizations_internal(struct dc *dc, bool allow, char const if (dc->clk_mgr != NULL && dc->clk_mgr->funcs->get_hard_min_memclk) idle_dramclk_khz = dc->clk_mgr->funcs->get_hard_min_memclk(dc->clk_mgr); - for (i = 0; i < dc->res_pool->pipe_count; i++) { - pipe = &context->res_ctx.pipe_ctx[i]; - subvp_pipe_type[i] = dc_state_get_pipe_subvp_type(context, pipe); + if (dc->res_pool && context) { + for (i = 0; i < dc->res_pool->pipe_count; i++) { + pipe = &context->res_ctx.pipe_ctx[i]; + subvp_pipe_type[i] = dc_state_get_pipe_subvp_type(context, pipe); + } } DC_LOG_DC("%s: allow_idle=%d\n HardMinUClk_Khz=%d HardMinDramclk_Khz=%d\n Pipe_0=%d Pipe_1=%d Pipe_2=%d Pipe_3=%d Pipe_4=%d Pipe_5=%d (caller=%s)\n", -- 2.39.5