lkml.org 
[lkml]   [2019]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/3] gpu: drm: dead code elimination
From
Date
On 2019-12-18 4:50 a.m., Pan Zhang wrote:
> this set adds support for removal of gpu drm dead code.
>
> patch2:
> `num_entries` is a data of unsigned type(compilers always treat as unsigned int) and SIZE_MAX == ~0,
>
> so there is a impossible condition:
> '(num_entries > ((~0) - 56) / 72) => (max(0-u32) > 256204778801521549)'.

While this looks correct for 64-bit, where size_t is unsigned long, on
32-bit it's unsigned int, in which case this isn't dead code.


> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> index 85b0515..10a7f30 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
> @@ -71,10 +71,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;
> -
> size = sizeof(struct amdgpu_bo_list);
> size += num_entries * sizeof(struct amdgpu_bo_list_entry);
> list = kvmalloc(size, GFP_KERNEL);
>


--
Earthling Michel Dänzer | https://redhat.com
Libre software enthusiast | Mesa and X developer

\
 
 \ /
  Last update: 2019-12-18 10:59    [W:0.034 / U:4.852 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site