Skip to contentSkip to conversation

tcm_vhost: Fix tv_cmd completion -> release SGL memory leak

PATCH In review Nicholas A. Bellinger 2 participants 3 messages Jul 5, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcm_vhost: Fix tv_cmd completion -> release SGL memory leak

From: Nicholas Bellinger <[email protected]>

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 <[email protected]>
Cc Zhi Yong Wu <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
---
 drivers/vhost/tcm_vhost.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/vhost/tcm_vhost.c +2 -0
index cd86633..9692153 100644
@@ -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);
Signature · 1 line
1.7.2.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

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 <[email protected]>
Cc Zhi Yong Wu <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
---
 drivers/vhost/tcm_vhost.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/vhost/tcm_vhost.c +0 -0
index cd86633..9692153 100644

drivers/vhost/tcm_vhost.c static void vhost_scsi_free_cmd(struct tcm_vhost_cmd *tv_cmd) · line 394

Quoted 8 lines
drivers/vhost/tcm_vhost.c +2 -0
@@ -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);
Signature · 3 lines
Regards,

Zhi Yong Wu
Reviewed-by on v1 1/1
#2 lore raw
In reply to Nicholas A. Bellinger
Quoted 19 lines · Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

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 <[email protected]>
Cc Zhi Yong Wu <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
---
 drivers/vhost/tcm_vhost.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/vhost/tcm_vhost.c +0 -0
index cd86633..9692153 100644

drivers/vhost/tcm_vhost.c static void vhost_scsi_free_cmd(struct tcm_vhost_cmd *tv_cmd) · line 394

Quoted 8 lines
drivers/vhost/tcm_vhost.c +2 -0
@@ -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);
Signature · 3 lines
Regards,

Zhi Yong Wu