From: Christophe JAILLET Date: Sun, 20 Aug 2023 09:51:14 +0000 (+0200) Subject: drm/amdgpu: Remove a redundant sanity check X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a23abe1fbdc16358ca185b4681fef19ec75b79c3;p=linux.git drm/amdgpu: Remove a redundant sanity check The case where 'num_entries' is too big, is already handled by struct_size(), because kvmalloc() would fail. It will return -ENOMEM instead of -EINVAL, but it is only related to a unlikely to happen sanity check. Signed-off-by: Christophe JAILLET Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c index 571fed04eb7a1..c8f59a044286d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c @@ -78,10 +78,6 @@ int amdgpu_bo_list_create(struct amdgpu_device *adev, struct drm_file *filp, unsigned i; int r; - if (num_entries > (SIZE_MAX - sizeof(struct amdgpu_bo_list)) - / sizeof(struct amdgpu_bo_list_entry)) - return -EINVAL; - list = kvmalloc(struct_size(list, entries, num_entries), GFP_KERNEL); if (!list) return -ENOMEM;