From: Alex Deucher <alexdeucher@gmail.com>
To: "Marion & Christophe JAILLET" <christophe.jaillet@wanadoo.fr>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
"Messinger, Ori" <Ori.Messinger@amd.com>,
Dave Airlie <airlied@linux.ie>, Bernard Zhao <bernard@vivo.com>,
kernel-janitors@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
Maling list - DRI developers <dri-devel@lists.freedesktop.org>,
Sumit Semwal <sumit.semwal@linaro.org>,
Colton Lewis <colton.w.lewis@protonmail.com>,
amd-gfx list <amd-gfx@lists.freedesktop.org>,
Daniel Vetter <daniel@ffwll.ch>,
"Deucher, Alexander" <alexander.deucher@amd.com>,
Christian Koenig <christian.koenig@amd.com>,
Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH] drm: amdgpu: Use the correct size when allocating memory
Date: Mon, 10 Aug 2020 17:15:44 -0400 [thread overview]
Message-ID: <CADnq5_NURN9_ONyXoLd5gMK6mTxotRZiP7N27UC1n_RNpQKimA@mail.gmail.com> (raw)
In-Reply-To: <8c414dd7-4a80-6ff2-03de-5340fb0d9c61@wanadoo.fr>
Applied and updated the commit message to reflect the sizes.
Thanks!
Alex
On Mon, Aug 10, 2020 at 3:07 PM Marion & Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
>
> Le 10/08/2020 à 17:42, Dan Carpenter a écrit :
> > On Sun, Aug 09, 2020 at 10:34:06PM +0200, Christophe JAILLET wrote:
> >> 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.
> > The sizeof(*sg) is bigger than sizeof(**sgt) so this wastes memory but
> > it won't lead to corruption.
> >
> > 11 struct scatterlist {
> > 12 unsigned long page_link;
> > 13 unsigned int offset;
> > 14 unsigned int length;
> > 15 dma_addr_t dma_address;
> > 16 #ifdef CONFIG_NEED_SG_DMA_LENGTH
> > 17 unsigned int dma_length;
> > 18 #endif
> > 19 };
> >
> > 42 struct sg_table {
> > 43 struct scatterlist *sgl; /* the list */
> > 44 unsigned int nents; /* number of mapped entries */
> > 45 unsigned int orig_nents; /* original size of list */
> > 46 };
> >
> > regards,
> > dan carpenter
>
>
> My bad. I read 'struct scatterlist sgl' (without the *)
> Thanks for the follow-up, Dan.
>
> Doesn't smatch catch such mismatch?
> (I've not run smatch for a while, so it is maybe reported)
>
> Well, the proposal is still valid, even if it has less impact as
> initially thought.
>
> Thx for the review.
>
> CJ
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2020-08-10 21:15 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
2020-08-10 15:42 ` Dan Carpenter
2020-08-10 18:41 ` Marion & Christophe JAILLET
2020-08-10 21:15 ` Alex Deucher [this message]
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=CADnq5_NURN9_ONyXoLd5gMK6mTxotRZiP7N27UC1n_RNpQKimA@mail.gmail.com \
--to=alexdeucher@gmail.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=christian.koenig@amd.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=colton.w.lewis@protonmail.com \
--cc=dan.carpenter@oracle.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).