Skip to contentSkip to conversation

virtio_scsi: fix memory leak on full queue condition.

PATCH In review Eric Northup 2 participants 2 messages Nov 8, 2012 – Nov 9, 2012

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

PATCH 1/1 virtio_scsi: fix memory leak on full queue condition.

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.

---
 drivers/scsi/virtio_scsi.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/scsi/virtio_scsi.c +2 -0
index 595af1a..dd8dc27 100644
@@ -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;
Signature · 1 line
1.7.7.3
maintainer Acked-by on v1 1/1
#1 lore raw

Il 08/11/2012 10:55, Eric Northup ha scritto:

Quoted 16 lines

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.

---
 drivers/scsi/virtio_scsi.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/scsi/virtio_scsi.c +0 -0
index 595af1a..dd8dc27 100644

drivers/scsi/virtio_scsi.c static int virtscsi_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc) · line 476

Quoted 8 lines
drivers/scsi/virtio_scsi.c +2 -0
@@ -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;

Paolo