mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2/3] gpu: drm: dead code elimination
@ 2019-12-18  3:50 Pan Zhang
  2019-12-18  9:52 ` Christian König
  2019-12-18  9:52 ` Michel Dänzer
  0 siblings, 2 replies; 4+ messages in thread
From: Pan Zhang @ 2019-12-18  3:50 UTC (permalink / raw)
  To: zhangpan26, hushiyuan, alexander.deucher, christian.koenig,
	David1.Zhou, airlied, daniel, ray.huang, irmoy.das, sam
  Cc: amd-gfx, dri-devel, linux-kernel

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)'.

Signed-off-by: Pan Zhang <zhangpan26@huawei.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 4 ----
 1 file changed, 4 deletions(-)

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);
-- 
2.7.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-19  3:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18  3:50 [PATCH 2/3] gpu: drm: dead code elimination Pan Zhang
2019-12-18  9:52 ` Christian König
2019-12-18  9:52 ` Michel Dänzer
2019-12-19  3:38   ` Pan Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®