Skip to contentSkip to conversation

scsi: fix calculation of phy_addr in mvumi_delete_internal_cmd

PATCH New Rand Deeb 1 participant 1 message Dec 16, 2023 SCSI

lore
Share & tools
lore

Rand Deeb

author
#0 lore raw

PATCH 1/1 scsi: fix calculation of phy_addr in mvumi_delete_internal_cmd

The calculation of phy_addr in mvumi_delete_internal_cmd contained an issue where the expression '(dma_addr_t) ((m_sg->baseaddr_h << 16) << 16)' was used. This expression was found to be incorrect and useless because it always evaluates to zero, regardless of the actual value of m_sg->baseaddr_h since it's u32.

This commit resolves the issue by placing the casting inside the brackets, making it more meaningful: (((dma_addr_t) m_sg->baseaddr_h << 16) << 16)

The corrected expression ensures that phy_addr is calculated correctly and addresses the previous issue, preventing the unnecessary use of a zero value.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/scsi/mvumi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/mvumi.c +1 -1
index 0354898d7cac..675ea5dcaa21 100644
@@ -296,7 +296,7 @@ static void mvumi_delete_internal_cmd(struct mvumi_hba *mhba,
 			sgd_getsz(mhba, m_sg, size);
 
 			phy_addr = (dma_addr_t) m_sg->baseaddr_l |
-				(dma_addr_t) ((m_sg->baseaddr_h << 16) << 16);
+				(((dma_addr_t) m_sg->baseaddr_h << 16) << 16);
 
 			dma_free_coherent(&mhba->pdev->dev, size, cmd->data_buf,
 								phy_addr);
Signature · 1 line
2.34.1