mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel@daenzer.net>
To: Pan Zhang <zhangpan26@huawei.com>,
	hushiyuan@huawei.com, alexander.deucher@amd.com,
	christian.koenig@amd.com, David1.Zhou@amd.com, airlied@linux.ie,
	daniel@ffwll.ch, ray.huang@amd.com, irmoy.das@amd.com,
	sam@ravnborg.org
Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] gpu: drm: dead code elimination
Date: Wed, 18 Dec 2019 10:52:18 +0100	[thread overview]
Message-ID: <484b831b-671a-12f4-8259-1cb6b75e93e3@daenzer.net> (raw)
In-Reply-To: <1576641000-14772-1-git-send-email-zhangpan26@huawei.com>

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

  parent reply	other threads:[~2019-12-18  9:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-18  3:50 Pan Zhang
2019-12-18  9:52 ` Christian König
2019-12-18  9:52 ` Michel Dänzer [this message]
2019-12-19  3:38   ` Pan Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=484b831b-671a-12f4-8259-1cb6b75e93e3@daenzer.net \
    --to=michel@daenzer.net \
    --cc=David1.Zhou@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hushiyuan@huawei.com \
    --cc=irmoy.das@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ray.huang@amd.com \
    --cc=sam@ravnborg.org \
    --cc=zhangpan26@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®