* [PATCH][next] drm/vmwgfx: Fix memory leak of object fifo on error return
@ 2021-05-12 19:56 Colin King
2021-05-14 14:30 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2021-05-12 19:56 UTC (permalink / raw)
To: VMware Graphics, Roland Scheidegger, Zack Rusin, David Airlie,
Daniel Vetter, dri-devel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
In the case where fifo->static_buffer fails to be allocated the
error return path neglects to kfree the fifo object. Fix this by
adding in the missing kfree.
Addresses-Coverity: ("Resource leak")
Fixes: 2cd80dbd3551 ("drm/vmwgfx: Add basic support for SVGA3")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c
index 027d7d504e78..e5fa210f589e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c
@@ -107,8 +107,10 @@ struct vmw_fifo_state *vmw_fifo_create(struct vmw_private *dev_priv)
fifo = kzalloc(sizeof(*fifo), GFP_KERNEL);
fifo->static_buffer_size = VMWGFX_FIFO_STATIC_SIZE;
fifo->static_buffer = vmalloc(fifo->static_buffer_size);
- if (unlikely(fifo->static_buffer == NULL))
+ if (unlikely(fifo->static_buffer == NULL)) {
+ kfree(fifo);
return ERR_PTR(-ENOMEM);
+ }
fifo->dynamic_buffer = NULL;
fifo->reserved_size = 0;
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][next] drm/vmwgfx: Fix memory leak of object fifo on error return
2021-05-12 19:56 [PATCH][next] drm/vmwgfx: Fix memory leak of object fifo on error return Colin King
@ 2021-05-14 14:30 ` Dan Carpenter
2021-05-14 14:32 ` Colin Ian King
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-05-14 14:30 UTC (permalink / raw)
To: Colin King
Cc: VMware Graphics, Roland Scheidegger, Zack Rusin, David Airlie,
Daniel Vetter, dri-devel, kernel-janitors, linux-kernel
On Wed, May 12, 2021 at 08:56:09PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> In the case where fifo->static_buffer fails to be allocated the
> error return path neglects to kfree the fifo object. Fix this by
> adding in the missing kfree.
>
> Addresses-Coverity: ("Resource leak")
> Fixes: 2cd80dbd3551 ("drm/vmwgfx: Add basic support for SVGA3")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c
> index 027d7d504e78..e5fa210f589e 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c
> @@ -107,8 +107,10 @@ struct vmw_fifo_state *vmw_fifo_create(struct vmw_private *dev_priv)
> fifo = kzalloc(sizeof(*fifo), GFP_KERNEL);
This needs an:
if (!fifo)
return -ENOMEM;
> fifo->static_buffer_size = VMWGFX_FIFO_STATIC_SIZE;
> fifo->static_buffer = vmalloc(fifo->static_buffer_size);
> - if (unlikely(fifo->static_buffer == NULL))
> + if (unlikely(fifo->static_buffer == NULL)) {
> + kfree(fifo);
> return ERR_PTR(-ENOMEM);
> + }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] drm/vmwgfx: Fix memory leak of object fifo on error return
2021-05-14 14:30 ` Dan Carpenter
@ 2021-05-14 14:32 ` Colin Ian King
0 siblings, 0 replies; 3+ messages in thread
From: Colin Ian King @ 2021-05-14 14:32 UTC (permalink / raw)
To: Dan Carpenter
Cc: VMware Graphics, Roland Scheidegger, Zack Rusin, David Airlie,
Daniel Vetter, dri-devel, kernel-janitors, linux-kernel
On 14/05/2021 15:30, Dan Carpenter wrote:
> On Wed, May 12, 2021 at 08:56:09PM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> In the case where fifo->static_buffer fails to be allocated the
>> error return path neglects to kfree the fifo object. Fix this by
>> adding in the missing kfree.
>>
>> Addresses-Coverity: ("Resource leak")
>> Fixes: 2cd80dbd3551 ("drm/vmwgfx: Add basic support for SVGA3")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>> drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c
>> index 027d7d504e78..e5fa210f589e 100644
>> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c
>> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c
>> @@ -107,8 +107,10 @@ struct vmw_fifo_state *vmw_fifo_create(struct vmw_private *dev_priv)
>> fifo = kzalloc(sizeof(*fifo), GFP_KERNEL);
>
> This needs an:
>
> if (!fifo)
> return -ENOMEM;
Doh, I completely missed that. I'll send a V2. Thanks Dan.
>
>> fifo->static_buffer_size = VMWGFX_FIFO_STATIC_SIZE;
>> fifo->static_buffer = vmalloc(fifo->static_buffer_size);
>> - if (unlikely(fifo->static_buffer == NULL))
>> + if (unlikely(fifo->static_buffer == NULL)) {
>> + kfree(fifo);
>> return ERR_PTR(-ENOMEM);
>> + }
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-14 14:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12 19:56 [PATCH][next] drm/vmwgfx: Fix memory leak of object fifo on error return Colin King
2021-05-14 14:30 ` Dan Carpenter
2021-05-14 14:32 ` Colin Ian King
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).