From: Hangyu Hua <hbh25y@gmail.com>
To: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@linux.ie, daniel@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] gpu: drm: fix possible memory leak in drm_addmap_core()
Date: Mon, 23 May 2022 09:57:46 +0800 [thread overview]
Message-ID: <ea67fa6b-0fcd-4b59-861f-360e74a4d70a@gmail.com> (raw)
In-Reply-To: <20220509054441.17282-1-hbh25y@gmail.com>
On 2022/5/9 13:44, Hangyu Hua wrote:
> map->handle need to be handled correctly when map->type is _DRM_SHM or
> _DRM_CONSISTENT just like map->type is _DRM_REGISTERS.
>
> Fixes: 8d153f7107ff ("drm: update user token hashing and map handles")
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
> ---
> drivers/gpu/drm/drm_bufs.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index fcca21e8efac..2b3f504c5f9c 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -344,6 +344,15 @@ static int drm_addmap_core(struct drm_device *dev, resource_size_t offset,
> if (!list) {
> if (map->type == _DRM_REGISTERS)
> iounmap(map->handle);
> + else if (map->type == _DRM_SHM) {
> + dev->sigdata.lock = dev->master->lock.hw_lock = NULL;
> + vfree(map->handle);
> + } else if (map->type == _DRM_CONSISTENT) {
> + dma_free_coherent(dev->dev,
> + map->size,
> + map->handle,
> + map->offset);
> + }
> kfree(map);
> return -EINVAL;
> }
> @@ -361,6 +370,15 @@ static int drm_addmap_core(struct drm_device *dev, resource_size_t offset,
> if (ret) {
> if (map->type == _DRM_REGISTERS)
> iounmap(map->handle);
> + else if (map->type == _DRM_SHM) {
> + dev->sigdata.lock = dev->master->lock.hw_lock = NULL;
> + vfree(map->handle);
> + } else if (map->type == _DRM_CONSISTENT) {
> + dma_free_coherent(dev->dev,
> + map->size,
> + map->handle,
> + map->offset);
> + }
> kfree(map);
> kfree(list);
> mutex_unlock(&dev->struct_mutex);
Gentel ping.
next prev parent reply other threads:[~2022-05-23 1:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-09 5:44 [PATCH] gpu: drm: fix possible memory leak in drm_addmap_core() Hangyu Hua
2022-05-23 1:57 ` Hangyu Hua [this message]
2022-06-23 1:45 ` Hangyu Hua
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=ea67fa6b-0fcd-4b59-861f-360e74a4d70a@gmail.com \
--to=hbh25y@gmail.com \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=tzimmermann@suse.de \
/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