From: "Christian König" <christian.koenig@amd.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
alexander.deucher@amd.com, airlied@linux.ie, daniel@ffwll.ch,
sumit.semwal@linaro.org, colton.w.lewis@protonmail.com,
Ori.Messinger@amd.com, m.szyprowski@samsung.com,
bernard@vivo.com, dri-devel@lists.freedesktop.org
Cc: amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] drm: amdgpu: Use the correct size when allocating memory
Date: Mon, 10 Aug 2020 11:36:45 +0200 [thread overview]
Message-ID: <b4117d15-d563-5e1e-d8ce-edded2db77a1@amd.com> (raw)
In-Reply-To: <20200809203406.751971-1-christophe.jaillet@wanadoo.fr>
Am 09.08.20 um 22:34 schrieb Christophe JAILLET:
> When '*sgt' is allocated, we must allocated 'sizeof(**sgt)' bytes instead
> of 'sizeof(*sg)'. 'sg' (i.e. struct scatterlist) is smaller than
> 'sgt' (i.e struct sg_table), so this could lead to memory corruption.
>
> Fixes: f44ffd677fb3 ("drm/amdgpu: add support for exporting VRAM using DMA-buf v3")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Good catch, Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index 134cc36e30c5..0739e259bf91 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -462,7 +462,7 @@ int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
> unsigned int pages;
> int i, r;
>
> - *sgt = kmalloc(sizeof(*sg), GFP_KERNEL);
> + *sgt = kmalloc(sizeof(**sgt), GFP_KERNEL);
> if (!*sgt)
> return -ENOMEM;
>
next prev parent reply other threads:[~2020-08-10 9:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-09 20:34 [PATCH] drm: amdgpu: Use the correct size when allocating memory Christophe JAILLET
2020-08-10 9:36 ` Christian König [this message]
2020-08-10 15:42 ` Dan Carpenter
2020-08-10 18:41 ` Marion & Christophe JAILLET
2020-08-10 21:15 ` Alex Deucher
2020-08-11 7:57 ` Dan Carpenter
2020-08-11 8:00 ` Dan Carpenter
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=b4117d15-d563-5e1e-d8ce-edded2db77a1@amd.com \
--to=christian.koenig@amd.com \
--cc=Ori.Messinger@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=bernard@vivo.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=colton.w.lewis@protonmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=sumit.semwal@linaro.org \
/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;
as well as URLs for NNTP newsgroup(s).