linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio_scsi: fix memory leak on full queue condition.
@ 2012-11-08  9:55 Eric Northup
  2012-11-09  8:48 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Northup @ 2012-11-08  9:55 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: James E.J. Bottomley, linux-scsi, linux-kernel, kvm, Eric Northup

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;
-- 
1.7.7.3

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

* Re: [PATCH] virtio_scsi: fix memory leak on full queue condition.
  2012-11-08  9:55 [PATCH] virtio_scsi: fix memory leak on full queue condition Eric Northup
@ 2012-11-09  8:48 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2012-11-09  8:48 UTC (permalink / raw)
  To: Eric Northup; +Cc: James E.J. Bottomley, linux-scsi, linux-kernel, kvm

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

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

end of thread, other threads:[~2012-11-09  8:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-08  9:55 [PATCH] virtio_scsi: fix memory leak on full queue condition Eric Northup
2012-11-09  8:48 ` Paolo Bonzini

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).