summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Wentland <harry.wentland@amd.com>2026-06-18 08:55:08 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-04 13:38:37 +0200
commit9540b0a4d13e4ede64ae1197d66a176d2149daa9 (patch)
tree9908634fb1549c71a6b20cc86a7a0419ecc12260
parent66e4b63d61c15de6ca5332d9ca6db59a404d7136 (diff)
downloadlinux-stable-9540b0a4d13e4ede64ae1197d66a176d2149daa9.tar.gz
linux-stable-9540b0a4d13e4ede64ae1197d66a176d2149daa9.zip
drm/amd/display: Use krealloc_array() in dal_vector_reserve()
[ Upstream commit da48bc4461b8a5ebfb9264c9b191a701d8e99009 ] [Why & How] dal_vector_reserve() computes the allocation size as "capacity * vector->struct_size" using uint32_t arithmetic, which can silently wrap to a small value on overflow. This would cause krealloc to return a smaller buffer than expected, leading to heap overflows on subsequent vector appends. Replace krealloc() with krealloc_array() which performs an internal overflow check and returns NULL on wrap, preventing the issue. Fixes: 2004f45ef83f ("drm/amd/display: Use kernel alloc/free") Assisted-by: Copilot:claude-opus-4.6 Reviewed-by: Alex Hung <alex.hung@amd.com> Signed-off-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Ray Wu <ray.wu@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 37668568641ccc4cc1dbca4923d0a16609dd5707) Cc: stable@vger.kernel.org [ changed `krealloc_array(p, capacity, struct_size)` to `krealloc(p, array_size(capacity, struct_size))` since krealloc_array() is absent in 5.10 ] Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/gpu/drm/amd/display/dc/basics/vector.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/basics/vector.c b/drivers/gpu/drm/amd/display/dc/basics/vector.c
index 8f93d25f91ee..68c34a4e253a 100644
--- a/drivers/gpu/drm/amd/display/dc/basics/vector.c
+++ b/drivers/gpu/drm/amd/display/dc/basics/vector.c
@@ -292,7 +292,7 @@ bool dal_vector_reserve(struct vector *vector, uint32_t capacity)
return true;
new_container = krealloc(vector->container,
- capacity * vector->struct_size, GFP_KERNEL);
+ array_size(capacity, vector->struct_size), GFP_KERNEL);
if (new_container) {
vector->container = new_container;