]> git.itanic.dy.fi Git - linux-stable/commit
drm/amd/display: fix shift-out-of-bounds in CalculateVMAndRowBytes
authorAlex Hung <alex.hung@amd.com>
Wed, 11 Jan 2023 16:54:11 +0000 (09:54 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:31:31 +0000 (13:31 +0100)
commitbec1bea2fa974e63f6059c33edde669c7894d0bc
tree336d18428756216ea5147800bcb8249606f5383c
parentf9252605b8f350080509d2378c343eb90ce6d18f
drm/amd/display: fix shift-out-of-bounds in CalculateVMAndRowBytes

[ Upstream commit 031f196d1b1b6d5dfcb0533b431e3ab1750e6189 ]

[WHY]
When PTEBufferSizeInRequests is zero, UBSAN reports the following
warning because dml_log2 returns an unexpected negative value:

  shift exponent 4294966273 is too large for 32-bit type 'int'

[HOW]

In the case PTEBufferSizeInRequests is zero, skip the dml_log2() and
assign the result directly.

Reviewed-by: Jun Lei <Jun.Lei@amd.com>
Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c