From: Robin Murphy <robin.murphy@arm.com>
To: Guchun Chen <guchun.chen@amd.com>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
christian.koenig@amd.com, xinhui.pan@amd.com,
alexander.deucher@amd.com
Cc: Leslie Shi <Yuliang.Shi@amd.com>
Subject: Re: [PATCH] drm/ttm: add a WARN_ON in ttm_set_driver_manager when array bounds (v2)
Date: Fri, 10 Sep 2021 19:24:40 +0100 [thread overview]
Message-ID: <868cab56-607b-bcc8-e358-b2475315f862@arm.com> (raw)
In-Reply-To: <20210910100922.12097-1-guchun.chen@amd.com>
On 2021-09-10 11:09, Guchun Chen wrote:
> Vendor will define their own memory types on top of TTM_PL_PRIV,
> but call ttm_set_driver_manager directly without checking mem_type
> value when setting up memory manager. So add such check to aware
> the case when array bounds.
>
> v2: lower check level to WARN_ON
>
> Signed-off-by: Leslie Shi <Yuliang.Shi@amd.com>
> Signed-off-by: Guchun Chen <guchun.chen@amd.com>
> ---
> include/drm/ttm/ttm_device.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/include/drm/ttm/ttm_device.h b/include/drm/ttm/ttm_device.h
> index 07d722950d5b..aa79953c807c 100644
> --- a/include/drm/ttm/ttm_device.h
> +++ b/include/drm/ttm/ttm_device.h
> @@ -291,6 +291,7 @@ ttm_manager_type(struct ttm_device *bdev, int mem_type)
> static inline void ttm_set_driver_manager(struct ttm_device *bdev, int type,
> struct ttm_resource_manager *manager)
> {
> + WARN_ON(type >= TTM_NUM_MEM_TYPES);
Nit: I know nothing about this code, but from the context alone it would
seem sensible to do
if (WARN_ON(type >= TTM_NUM_MEM_TYPES))
return;
to avoid making the subsequent assignment when we *know* it's invalid
and likely to corrupt memory.
Robin.
> bdev->man_drv[type] = manager;
> }
>
>
next prev parent reply other threads:[~2021-09-13 7:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-10 10:09 [PATCH] drm/ttm: add a WARN_ON in ttm_set_driver_manager when array bounds (v2) Guchun Chen
2021-09-10 18:24 ` Robin Murphy [this message]
2021-09-13 2:35 ` Chen, Guchun
2021-09-13 6:23 ` Christian König
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=868cab56-607b-bcc8-e358-b2475315f862@arm.com \
--to=robin.murphy@arm.com \
--cc=Yuliang.Shi@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=guchun.chen@amd.com \
--cc=xinhui.pan@amd.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