From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
"airlied@gmail.com" <airlied@gmail.com>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"daniel@ffwll.ch" <daniel@ffwll.ch>,
"suijingfeng@loongson.cn" <suijingfeng@loongson.cn>,
"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>
Cc: "dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"amergnat@baylibre.com" <amergnat@baylibre.com>
Subject: Re: [PATCH v2] drm/mediatek: Fix potential memory leak if vmap() fail
Date: Thu, 27 Jul 2023 01:47:31 +0000 [thread overview]
Message-ID: <6c639e58198680a8d2fb903bb27184bd328e2d54.camel@mediatek.com> (raw)
In-Reply-To: <20230706134000.130098-1-suijingfeng@loongson.cn>
Hi, Jingfeng:
On Thu, 2023-07-06 at 21:40 +0800, Sui Jingfeng wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> Also return -ENOMEM if such a failure happens, the implement should
> take
> responsibility for the error handling.
Reviewed-by: CK Hu <ck.hu@mediatek.com>
>
> Fixes: 3df64d7b0a4f ("drm/mediatek: Implement gem prime vmap/vunmap
> function")
> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
> Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
> ---
> drivers/gpu/drm/mediatek/mtk_drm_gem.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c
> b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
> index a25b28d3ee90..9f364df52478 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
> @@ -247,7 +247,11 @@ int mtk_drm_gem_prime_vmap(struct drm_gem_object
> *obj, struct iosys_map *map)
>
> mtk_gem->kvaddr = vmap(mtk_gem->pages, npages, VM_MAP,
> pgprot_writecombine(PAGE_KERNEL));
> -
> + if (!mtk_gem->kvaddr) {
> + kfree(sgt);
> + kfree(mtk_gem->pages);
> + return -ENOMEM;
> + }
> out:
> kfree(sgt);
> iosys_map_set_vaddr(map, mtk_gem->kvaddr);
> --
> 2.34.1
next prev parent reply other threads:[~2023-07-27 1:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-06 13:40 Sui Jingfeng
2023-07-27 1:47 ` CK Hu (胡俊光) [this message]
2023-07-27 7:24 ` suijingfeng
2023-07-27 9:22 ` AngeloGioacchino Del Regno
2023-07-27 9:56 ` suijingfeng
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=6c639e58198680a8d2fb903bb27184bd328e2d54.camel@mediatek.com \
--to=ck.hu@mediatek.com \
--cc=airlied@gmail.com \
--cc=amergnat@baylibre.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=suijingfeng@loongson.cn \
/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®