summaryrefslogtreecommitdiff
path: root/drivers/ddr/altera/sdram_soc64.c
diff options
context:
space:
mode:
authorNaresh Kumar Ravulapalli <nareshkumar.ravulapalli@altera.com>2025-03-07 02:28:51 -0800
committerTien Fong Chee <tien.fong.chee@intel.com>2025-04-22 11:47:38 +0800
commitc889ca7ccf9ea960d164ee8568eb44e5c2f9a46d (patch)
treec611c8028b56b636dde7ef06bcbb9f7a2981632f /drivers/ddr/altera/sdram_soc64.c
parentcde0050618968aae335dfbc930641656d51ff5d0 (diff)
drivers: ddr: altera: Fix integer overflow during size calculation
Data structure, dramaddrw, is defined as u32. Compiler performs 32-bit arithmetic and logic operations on this data structure. Fix is provided to avoid integer overflow while performing shifting operations greater than 32-bit. Signed-off-by: Naresh Kumar Ravulapalli <nareshkumar.ravulapalli@altera.com> Reviewed-by: Tien Fong Chee <tien.fong.chee@altera.com>
Diffstat (limited to 'drivers/ddr/altera/sdram_soc64.c')
-rw-r--r--drivers/ddr/altera/sdram_soc64.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/ddr/altera/sdram_soc64.c b/drivers/ddr/altera/sdram_soc64.c
index c8c9211adce..75c6de1e4ec 100644
--- a/drivers/ddr/altera/sdram_soc64.c
+++ b/drivers/ddr/altera/sdram_soc64.c
@@ -249,7 +249,7 @@ phys_size_t sdram_calculate_size(struct altera_sdram_plat *plat)
DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +
DRAMADDRW_CFG_COL_ADDR_WIDTH(dramaddrw));
- size *= (2 << (hmc_ecc_readl(plat, DDRIOCTRL) &
+ size *= ((phys_size_t)2 << (hmc_ecc_readl(plat, DDRIOCTRL) &
DDR_HMC_DDRIOCTRL_IOSIZE_MSK));
return size;