Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: mvsas: 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: b5762948263d ("[SCSI] mvsas: Add Marvell 6440 SAS/SATA driver")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Link: https://lore.kernel.org/r/20250627134822.234813-2-fourier.thomas@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Thomas Fourier and committed by
Martin K. Petersen
01416187 3a988d0b

+2 -2
+2 -2
drivers/scsi/mvsas/mv_sas.c
··· 818 818 dev_printk(KERN_ERR, mvi->dev, "mvsas prep failed[%d]!\n", rc); 819 819 if (!sas_protocol_ata(task->task_proto)) 820 820 if (n_elem) 821 - dma_unmap_sg(mvi->dev, task->scatter, n_elem, 821 + dma_unmap_sg(mvi->dev, task->scatter, task->num_scatter, 822 822 task->data_dir); 823 823 prep_out: 824 824 return rc; ··· 864 864 if (!sas_protocol_ata(task->task_proto)) 865 865 if (slot->n_elem) 866 866 dma_unmap_sg(mvi->dev, task->scatter, 867 - slot->n_elem, task->data_dir); 867 + task->num_scatter, task->data_dir); 868 868 869 869 switch (task->task_proto) { 870 870 case SAS_PROTOCOL_SMP: