public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tcm_vhost: Fix tv_cmd completion -> release SGL memory leak
@ 2012-07-05  4:14 Nicholas A. Bellinger
  2012-07-05  5:24 ` Zhi Yong Wu
  0 siblings, 1 reply; 2+ messages in thread
From: Nicholas A. Bellinger @ 2012-07-05  4:14 UTC (permalink / raw)
  To: target-devel
  Cc: linux-scsi, lf-virt, kvm-devel, Stefan Hajnoczi, Zhi Yong Wu,
	Paolo Bonzini, Michael S. Tsirkin, Nicholas Bellinger

From: Nicholas Bellinger <nab@linux-iscsi.org>

The SGL memory allocated during vhost_scsi_map_iov_to_sgl() setup was never
getting freed during tv_cmd completion -> release path.  Fix this up by releasing
tv_cmd->tvc_sgl in vhost_scsi_free_cmd() ahead of tv_cmd descriptor free.

Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: Zhi Yong Wu <wuzhy@cn.ibm.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
---
 drivers/vhost/tcm_vhost.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
index cd86633..9692153 100644
--- a/drivers/vhost/tcm_vhost.c
+++ b/drivers/vhost/tcm_vhost.c
@@ -387,6 +387,8 @@ static void vhost_scsi_free_cmd(struct tcm_vhost_cmd *tv_cmd)
 		u32 i;
 		for (i = 0; i < tv_cmd->tvc_sgl_count; i++)
 			put_page(sg_page(&tv_cmd->tvc_sgl[i]));
+
+		kfree(tv_cmd->tvc_sgl);
 	}
 
 	kfree(tv_cmd);
-- 
1.7.2.5

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

* Re: [PATCH] tcm_vhost: Fix tv_cmd completion -> release SGL memory leak
  2012-07-05  4:14 [PATCH] tcm_vhost: Fix tv_cmd completion -> release SGL memory leak Nicholas A. Bellinger
@ 2012-07-05  5:24 ` Zhi Yong Wu
  0 siblings, 0 replies; 2+ messages in thread
From: Zhi Yong Wu @ 2012-07-05  5:24 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: target-devel, Stefan Hajnoczi, kvm-devel, Michael S. Tsirkin,
	Zhi Yong Wu, linux-scsi, Paolo Bonzini, lf-virt

On Thu, 2012-07-05 at 04:14 +0000, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
> 
> The SGL memory allocated during vhost_scsi_map_iov_to_sgl() setup was never
> getting freed during tv_cmd completion -> release path.  Fix this up by releasing
> tv_cmd->tvc_sgl in vhost_scsi_free_cmd() ahead of tv_cmd descriptor free.
> 
> Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> Cc: Zhi Yong Wu <wuzhy@cn.ibm.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> ---
>  drivers/vhost/tcm_vhost.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
> index cd86633..9692153 100644
> --- a/drivers/vhost/tcm_vhost.c
> +++ b/drivers/vhost/tcm_vhost.c
> @@ -387,6 +387,8 @@ static void vhost_scsi_free_cmd(struct tcm_vhost_cmd *tv_cmd)
>  		u32 i;
>  		for (i = 0; i < tv_cmd->tvc_sgl_count; i++)
>  			put_page(sg_page(&tv_cmd->tvc_sgl[i]));
> +
> +		kfree(tv_cmd->tvc_sgl);
>  	}
> 
>  	kfree(tv_cmd);

Reviewed-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

-- 
Regards,

Zhi Yong Wu


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

end of thread, other threads:[~2012-07-05  5:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-05  4:14 [PATCH] tcm_vhost: Fix tv_cmd completion -> release SGL memory leak Nicholas A. Bellinger
2012-07-05  5:24 ` Zhi Yong Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox