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 D9FB6C4167B for ; Sun, 12 Nov 2023 13:28:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DD0C510E135; Sun, 12 Nov 2023 13:27:57 +0000 (UTC) Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id B00D110E135; Sun, 12 Nov 2023 13:27:55 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C824DCE0C6C; Sun, 12 Nov 2023 13:27:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 207EEC433C7; Sun, 12 Nov 2023 13:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699795671; bh=buC1oeGTRb3fsjSYX6LJpcpwd63Gjd5Rkxbxzu4PLtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u5rAAGTYzOcx8VUeU/CTJt+4mv/tJQc4BZJXIXPyQsXHnWBhhRzdULWfPK/6eh76C PrMN+W41nNGM1RXZ4rxXoxEsndvsm/F1HK0isWlp5hAflkC6H7lEGFdCOpmFWgtpHo LHR5pvV/EQG8pWk+64ihyNc1yzisEFmbP7L7wl0BqMuDMd/VR/zcO1q00qioPw15zS N5SKTeiHBHQ6SCRd4xsnK5EPg8HnDQpoV5SZXsEwkpkVS8TiHf/LXUrrJ/qFxxf0K1 UG35mJMpadHVsobN9HIKcaKW/H4udYYvCjihhGxtJGMUNx3Yg+Or9084mUWOkS5udz atqKe0GC4yfOA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 10/11] drm/amd/display: Avoid NULL dereference of timing generator Date: Sun, 12 Nov 2023 08:27:33 -0500 Message-ID: <20231112132736.175494-10-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231112132736.175494-1-sashal@kernel.org> References: <20231112132736.175494-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.1 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , airlied@linux.ie, amd-gfx@lists.freedesktop.org, Daniel Wheeler , Hersen Wu , dri-devel@lists.freedesktop.org, Wayne Lin , Alex Deucher , Jun Lei , christian.koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Wayne Lin [ Upstream commit b1904ed480cee3f9f4036ea0e36d139cb5fee2d6 ] [Why & How] Check whether assigned timing generator is NULL or not before accessing its funcs to prevent NULL dereference. Reviewed-by: Jun Lei Acked-by: Hersen Wu Signed-off-by: Wayne Lin Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c index 01fe2d2fd2417..ebe571fcefe32 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c @@ -582,7 +582,7 @@ uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream) for (i = 0; i < MAX_PIPES; i++) { struct timing_generator *tg = res_ctx->pipe_ctx[i].stream_res.tg; - if (res_ctx->pipe_ctx[i].stream != stream) + if (res_ctx->pipe_ctx[i].stream != stream || !tg) continue; return tg->funcs->get_frame_count(tg); @@ -641,7 +641,7 @@ bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream, for (i = 0; i < MAX_PIPES; i++) { struct timing_generator *tg = res_ctx->pipe_ctx[i].stream_res.tg; - if (res_ctx->pipe_ctx[i].stream != stream) + if (res_ctx->pipe_ctx[i].stream != stream || !tg) continue; tg->funcs->get_scanoutpos(tg, -- 2.42.0