Skip to content

Commit 375150b

Browse files
arndbgregkh
authored andcommitted
drm/amdgpu: fix warning for overflow check
[ Upstream commit 335aea7 ] The overflow check in amdgpu_bo_list_create() causes a warning with clang-14 on 64-bit architectures, since the limit can never be exceeded. drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c:74:18: error: result of comparison of constant 256204778801521549 with expression of type 'unsigned int' is always false [-Werror,-Wtautological-constant-out-of-range-compare] if (num_entries > (SIZE_MAX - sizeof(struct amdgpu_bo_list)) ~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The check remains useful for 32-bit architectures, so just avoid the warning by using size_t as the type for the count. Fixes: 920990c ("drm/amdgpu: allocate the bo_list array after the list") Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8980f9d commit 375150b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static void amdgpu_bo_list_free(struct kref *ref)
6161

6262
int amdgpu_bo_list_create(struct amdgpu_device *adev, struct drm_file *filp,
6363
struct drm_amdgpu_bo_list_entry *info,
64-
unsigned num_entries, struct amdgpu_bo_list **result)
64+
size_t num_entries, struct amdgpu_bo_list **result)
6565
{
6666
unsigned last_entry = 0, first_userptr = num_entries;
6767
struct amdgpu_bo_list_entry *array;

‎drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int amdgpu_bo_create_list_entry_array(struct drm_amdgpu_bo_list_in *in,
6060
int amdgpu_bo_list_create(struct amdgpu_device *adev,
6161
struct drm_file *filp,
6262
struct drm_amdgpu_bo_list_entry *info,
63-
unsigned num_entries,
63+
size_t num_entries,
6464
struct amdgpu_bo_list **list);
6565

6666
static inline struct amdgpu_bo_list_entry *

0 commit comments

Comments
 (0)