[SCSI] virtio_scsi: fix memory leak on full queue condition.
authorEric Northup <digitaleric@google.com>
Thu, 8 Nov 2012 09:55:50 +0000 (01:55 -0800)
committerJames Bottomley <JBottomley@Parallels.com>
Tue, 27 Nov 2012 04:59:45 +0000 (08:59 +0400)
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>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/virtio_scsi.c

index 595af1a..dd8dc27 100644 (file)
@@ -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;