Skip to contentSkip to conversation

ibmvfc: Fix DMA mapping leak on memory allocation failure

PATCH New Brian King 1 participant 1 message Jan 22, 2009

Subsystems (3)
lore
Share & tools
lore

Brian King

author
#0 lore raw

PATCH 1/1 ibmvfc: Fix DMA mapping leak on memory allocation failure

There is currently a DMA mapping leak that can occur in the ibmvfc driver if we fail to allocate a scatterlist. Fix this by unmapping the scatterlist in the failure path. Additionally, only log an error for a scatterlist allocation failure if the log level is greater than the default, since this can occur when running Active Memory Sharing and this is not considered an error.

---

 drivers/scsi/ibmvscsi/ibmvfc.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/ibmvscsi/ibmvfc.c renamed from drivers/scsi/ibmvscsi/ibmvfc.c~ibmvfc_cmo_fixes +3 -1
diff -puN drivers/scsi/ibmvscsi/ibmvfc.c~ibmvfc_cmo_fixes drivers/scsi/ibmvscsi/ibmvfc.c
@@ -1322,7 +1322,9 @@ static int ibmvfc_map_sg_data(struct scs
 					       &evt->ext_list_token);
 
 		if (!evt->ext_list) {
-			scmd_printk(KERN_ERR, scmd, "Can't allocate memory for scatterlist\n");
+			scsi_dma_unmap(scmd);
+			if (vhost->log_level > IBMVFC_DEFAULT_LOG_LEVEL)
+				scmd_printk(KERN_ERR, scmd, "Can't allocate memory for scatterlist\n");
 			return -ENOMEM;
 		}
 	}

_