All of lore.kernel.org
 help / color / mirror / Atom feed
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: Thu, 23 Jun 2022 09:45:46 +0800	[thread overview]
Message-ID: <b0d778de-9be7-f1a0-9356-9daa398edf5e@gmail.com> (raw)
In-Reply-To: <ea67fa6b-0fcd-4b59-861f-360e74a4d70a@gmail.com>

On 2022/5/23 09:57, Hangyu Hua wrote:
> 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.

Gentel ping.

WARNING: multiple messages have this Message-ID (diff)
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: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] gpu: drm: fix possible memory leak in drm_addmap_core()
Date: Thu, 23 Jun 2022 09:45:46 +0800	[thread overview]
Message-ID: <b0d778de-9be7-f1a0-9356-9daa398edf5e@gmail.com> (raw)
In-Reply-To: <ea67fa6b-0fcd-4b59-861f-360e74a4d70a@gmail.com>

On 2022/5/23 09:57, Hangyu Hua wrote:
> 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.

Gentel ping.

  reply	other threads:[~2022-06-23  1:45 UTC|newest]

Thread overview: 6+ 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-09  5:44 ` Hangyu Hua
2022-05-23  1:57 ` Hangyu Hua
2022-05-23  1:57   ` Hangyu Hua
2022-06-23  1:45   ` 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=b0d778de-9be7-f1a0-9356-9daa398edf5e@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.