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 EBAF3C4332F for ; Sun, 12 Nov 2023 13:28:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5CD4310E155; Sun, 12 Nov 2023 13:28:19 +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 93EFD10E152; Sun, 12 Nov 2023 13:28:15 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 89ABACE0C6C; Sun, 12 Nov 2023 13:28:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89786C433C7; Sun, 12 Nov 2023 13:28:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699795692; bh=PwQQ/qj4qRnuUde0f1x1kHmBhsT7dkxvBgtJO1lWEbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HVtV69u/ejPEJYayIj9riXs3ncr90/TK6cD3HkkobWhihVgOWqPlin7njMRoW8wQR x6kg3TONVaF21wvF9aOTNZGgAp4y06SjVhr54MIVOU17Q71dH4Zx+9yxRo64Oy9axT qXM4nszcp9mOmf7c8tAoNP+hykJqu9a5BQ7xKJeiCN4xAREKPbZbh8ReRup5po0Q5L szElj4nzW3uNnZVraVmHJhQXa2SsfrDyJHnLbkQpSjBXptSCp9AsnebhlQ2yvuO3b+ j4MmbP+P+EGOfFhFnjJB/qO6GACyqdiNmTXrhndT/mbGHgLFnC7e59vifrZA/nQLSV SOYtK7GY9VvaQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 6.5 10/10] drm/amd/display: Avoid NULL dereference of timing generator Date: Sun, 12 Nov 2023 08:27:53 -0500 Message-ID: <20231112132755.175757-10-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231112132755.175757-1-sashal@kernel.org> References: <20231112132755.175757-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.11 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 6e11d2b701f82..569d40eb7059d 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c @@ -556,7 +556,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); @@ -615,7 +615,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