diff mbox

virtio_scsi: fix memory leak on full queue condition.

Message ID 1352368550-6694-1-git-send-email-digitaleric@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eric Northup Nov. 8, 2012, 9:55 a.m. UTC
virtscsi_queuecommand was leaking memory when the virtio queue was full.

Tested: Guest operates correctly even with very small queue sizes, validated
we're not leaking kmalloc-192 sized allocations anymore.

Signed-off-by: Eric Northup <digitaleric@google.com>
---
 drivers/scsi/virtio_scsi.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Paolo Bonzini Nov. 9, 2012, 8:48 a.m. UTC | #1
Il 08/11/2012 10:55, Eric Northup ha scritto:
> virtscsi_queuecommand was leaking memory when the virtio queue was full.
> 
> Tested: Guest operates correctly even with very small queue sizes, validated
> we're not leaking kmalloc-192 sized allocations anymore.
> 
> Signed-off-by: Eric Northup <digitaleric@google.com>
> ---
>  drivers/scsi/virtio_scsi.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 595af1a..dd8dc27 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -469,6 +469,8 @@ static int virtscsi_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
>  			      sizeof cmd->req.cmd, sizeof cmd->resp.cmd,
>  			      GFP_ATOMIC) >= 0)
>  		ret = 0;
> +	else
> +		mempool_free(cmd, virtscsi_cmd_pool);
>  
>  out:
>  	return ret;
> 

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 595af1a..dd8dc27 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -469,6 +469,8 @@  static int virtscsi_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
 			      sizeof cmd->req.cmd, sizeof cmd->resp.cmd,
 			      GFP_ATOMIC) >= 0)
 		ret = 0;
+	else
+		mempool_free(cmd, virtscsi_cmd_pool);
 
 out:
 	return ret;