Skip to contentSkip to conversation

ibmvscsis: Fix dma_unmap_sg() nents value

PATCH Applied Thomas Fourier 2 participants 3 messages Jun 30, 2025 – Jul 22, 2025

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

PATCH 1/1 ibmvscsis: Fix dma_unmap_sg() nents value

The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.

Fixes 88a678bbc34c ("ibmvscsis: Initial commit of IBM VSCSI Tgt Driver")
---
 drivers/scsi/ibmvscsi_tgt/libsrp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/ibmvscsi_tgt/libsrp.c +4 -2
index 8a0e28aec928..0ecad398ed3d 100644
@@ -184,7 +184,8 @@ static int srp_direct_data(struct ibmvscsis_cmd *cmd, struct srp_direct_buf *md,
 	err = rdma_io(cmd, sg, nsg, md, 1, dir, len);
 
 	if (dma_map)
-		dma_unmap_sg(iue->target->dev, sg, nsg, DMA_BIDIRECTIONAL);
+		dma_unmap_sg(iue->target->dev, sg, cmd->se_cmd.t_data_nents,
+			     DMA_BIDIRECTIONAL);
 
 	return err;
 }
@@ -256,7 +257,8 @@ static int srp_indirect_data(struct ibmvscsis_cmd *cmd, struct srp_cmd *srp_cmd,
 	err = rdma_io(cmd, sg, nsg, md, nmd, dir, len);
 
 	if (dma_map)
-		dma_unmap_sg(iue->target->dev, sg, nsg, DMA_BIDIRECTIONAL);
+		dma_unmap_sg(iue->target->dev, sg, cmd->se_cmd.t_data_nents,
+			     DMA_BIDIRECTIONAL);
 
 free_mem:
 	if (token && dma_map) {
Signature · 1 line
2.43.0
#1 lore raw

Thomas,

Quoted 2 lines

The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.

Applied to 6.17/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen