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>
This commit is contained in:

committed by
Tien Fong Chee

parent
cde0050618
commit
c889ca7ccf
@@ -249,7 +249,7 @@ phys_size_t sdram_calculate_size(struct altera_sdram_plat *plat)
|
|||||||
DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +
|
DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +
|
||||||
DRAMADDRW_CFG_COL_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));
|
DDR_HMC_DDRIOCTRL_IOSIZE_MSK));
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
Reference in New Issue
Block a user