[PATCH v8 7/8] scsi: mvumi: fix the DMA address rebuilt in mvumi_delete_internal_cmd()
From: Yehyeong Lee
Date: Wed Oct 14 2026 - 22:33:08 EST
mvumi_internal_cmd_sgl() splits the address of the internal command's data
buffer across two u32 fields, lower_32_bits() in baseaddr_l and
upper_32_bits() in baseaddr_h. mvumi_delete_internal_cmd() puts it back
together with
phy_addr = (dma_addr_t) m_sg->baseaddr_l |
(dma_addr_t) ((m_sg->baseaddr_h << 16) << 16);
but baseaddr_h is a u32, so both shifts happen in 32-bit arithmetic and the
result is zero. Every byte of the upper half is dropped, and on a 64-bit
host whose DMA mask let the buffer land above 4G, dma_free_coherent() is
handed an address that is not the one it returned.
Shift in u64 and cast once. Where dma_addr_t is 32 bits the cast truncates
to what lower_32_bits() stored, and upper_32_bits() stored zero, so the
result is unchanged there.
Fixes: f0c568a478f0 ("[SCSI] mvumi: Add Marvell UMI driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Yehyeong Lee <yhlee@xxxxxxxxxxxxxxxxxx>
---
drivers/scsi/mvumi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
index 2410d2aa147d9..bd1a8c1d54aeb 100644
--- a/drivers/scsi/mvumi.c
+++ b/drivers/scsi/mvumi.c
@@ -295,8 +295,8 @@ static void mvumi_delete_internal_cmd(struct mvumi_hba *mhba,
m_sg = (struct mvumi_sgl *) &cmd->frame->payload[0];
sgd_getsz(mhba, m_sg, size);
- phy_addr = (dma_addr_t) m_sg->baseaddr_l |
- (dma_addr_t) ((m_sg->baseaddr_h << 16) << 16);
+ phy_addr = (dma_addr_t)(((u64)m_sg->baseaddr_h << 32) |
+ m_sg->baseaddr_l);
dma_free_coherent(&mhba->pdev->dev, size, cmd->data_buf,
phy_addr);
--
2.43.0