From: Jesse Zhang Date: Wed, 29 May 2024 09:29:01 +0000 (+0800) Subject: drm/amdgu: fix Unintentional integer overflow for mall size X-Git-Tag: v6.11-rc1~141^2~25^2~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c09d2eff81a997c169e0cacacd6b60c5e3aa33f2;p=thirdparty%2Fkernel%2Flinux.git drm/amdgu: fix Unintentional integer overflow for mall size Potentially overflowing expression mall_size_per_umc * adev->gmc.num_umc with type unsigned int (32 bits, unsigned) is evaluated using 32-bit arithmetic,and then used in a context that expects an expression of type u64 (64 bits, unsigned). Signed-off-by: Jesse Zhang Reviewed-by: Christian König Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c index 87b31ed8de19d..c71356cb393d1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c @@ -1629,7 +1629,7 @@ static int amdgpu_discovery_get_mall_info(struct amdgpu_device *adev) break; case 2: mall_size_per_umc = le32_to_cpu(mall_info->v2.mall_size_per_umc); - adev->gmc.mall_size = mall_size_per_umc * adev->gmc.num_umc; + adev->gmc.mall_size = (uint64_t)mall_size_per_umc * adev->gmc.num_umc; break; default: dev_err(adev->dev,