linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/vmwgfx: fix memory leak when too many retries have occurred
@ 2019-06-21 22:35 Colin King
  2019-06-24 16:10 ` Deepak Singh Rawat
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2019-06-21 22:35 UTC (permalink / raw)
  To: VMware Graphics, Thomas Hellstrom, David Airlie, Daniel Vetter,
	dri-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently when too many retries have occurred there is a memory
leak on the allocation for reply on the error return path. Fix
this by kfree'ing reply before returning.

Addresses-Coverity: ("Resource leak")
Fixes: a9cd9c044aa9 ("drm/vmwgfx: Add a check to handle host message failure")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
index 8b9270f31409..8b61f16f50cf 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -301,8 +301,10 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg,
 		break;
 	}
 
-	if (retries == RETRIES)
+	if (retries == RETRIES) {
+		kfree(reply);
 		return -EINVAL;
+	}
 
 	*msg_len = reply_len;
 	*msg     = reply;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/vmwgfx: fix memory leak when too many retries have occurred
  2019-06-21 22:35 [PATCH] drm/vmwgfx: fix memory leak when too many retries have occurred Colin King
@ 2019-06-24 16:10 ` Deepak Singh Rawat
  2019-06-24 16:13   ` Colin Ian King
  0 siblings, 1 reply; 3+ messages in thread
From: Deepak Singh Rawat @ 2019-06-24 16:10 UTC (permalink / raw)
  To: Colin King, Linux-graphics-maintainer, Thomas Hellstrom,
	David Airlie, Daniel Vetter, dri-devel
  Cc: kernel-janitors, linux-kernel

Hi Colin,

Thanks for doing this.

Reviewed-by: Deepak Rawat <drawat@vmware.com>

Do you want me to include this in vmwgfx-next or will you submit this
via drm-mics?

On Fri, 2019-06-21 at 23:35 +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently when too many retries have occurred there is a memory
> leak on the allocation for reply on the error return path. Fix
> this by kfree'ing reply before returning.
> 
> Addresses-Coverity: ("Resource leak")
> Fixes: a9cd9c044aa9 ("drm/vmwgfx: Add a check to handle host message
> failure")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
> b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
> index 8b9270f31409..8b61f16f50cf 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
> @@ -301,8 +301,10 @@ static int vmw_recv_msg(struct rpc_channel
> *channel, void **msg,
>  		break;
>  	}
>  
> -	if (retries == RETRIES)
> +	if (retries == RETRIES) {
> +		kfree(reply);
>  		return -EINVAL;
> +	}
>  
>  	*msg_len = reply_len;
>  	*msg     = reply;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/vmwgfx: fix memory leak when too many retries have occurred
  2019-06-24 16:10 ` Deepak Singh Rawat
@ 2019-06-24 16:13   ` Colin Ian King
  0 siblings, 0 replies; 3+ messages in thread
From: Colin Ian King @ 2019-06-24 16:13 UTC (permalink / raw)
  To: Deepak Singh Rawat, Linux-graphics-maintainer, Thomas Hellstrom,
	David Airlie, Daniel Vetter, dri-devel
  Cc: kernel-janitors, linux-kernel

On 24/06/2019 17:10, Deepak Singh Rawat wrote:
> Hi Colin,
> 
> Thanks for doing this.
> 
> Reviewed-by: Deepak Rawat <drawat@vmware.com>
> 
> Do you want me to include this in vmwgfx-next or will you submit this
> via drm-mics?

Can you include it into vmwgfx-next?

Thanks

Colin

> 
> On Fri, 2019-06-21 at 23:35 +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently when too many retries have occurred there is a memory
>> leak on the allocation for reply on the error return path. Fix
>> this by kfree'ing reply before returning.
>>
>> Addresses-Coverity: ("Resource leak")
>> Fixes: a9cd9c044aa9 ("drm/vmwgfx: Add a check to handle host message
>> failure")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
>> b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
>> index 8b9270f31409..8b61f16f50cf 100644
>> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
>> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
>> @@ -301,8 +301,10 @@ static int vmw_recv_msg(struct rpc_channel
>> *channel, void **msg,
>>  		break;
>>  	}
>>  
>> -	if (retries == RETRIES)
>> +	if (retries == RETRIES) {
>> +		kfree(reply);
>>  		return -EINVAL;
>> +	}
>>  
>>  	*msg_len = reply_len;
>>  	*msg     = reply;
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-24 16:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-21 22:35 [PATCH] drm/vmwgfx: fix memory leak when too many retries have occurred Colin King
2019-06-24 16:10 ` Deepak Singh Rawat
2019-06-24 16:13   ` 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).