aspeed/smc: Fix potential overflow
Coverity warns that "ssi_transfer(s->spi, 0U) << 8 * i" might overflow because the expression is evaluated using 32-bit arithmetic and then used in a context expecting a uint64_t. Fixes: Coverity CID 1487244 Message-Id: <20220628165512.1133590-1-clg@kaod.org> Signed-off-by: Cédric Le Goater <clg@kaod.org>
This commit is contained in:
parent
0dbf6dc576
commit
75dbf30be8
@ -488,7 +488,7 @@ static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr addr, unsigned size)
|
|||||||
switch (aspeed_smc_flash_mode(fl)) {
|
switch (aspeed_smc_flash_mode(fl)) {
|
||||||
case CTRL_USERMODE:
|
case CTRL_USERMODE:
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
ret |= ssi_transfer(s->spi, 0x0) << (8 * i);
|
ret |= (uint64_t) ssi_transfer(s->spi, 0x0) << (8 * i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CTRL_READMODE:
|
case CTRL_READMODE:
|
||||||
@ -497,7 +497,7 @@ static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr addr, unsigned size)
|
|||||||
aspeed_smc_flash_setup(fl, addr);
|
aspeed_smc_flash_setup(fl, addr);
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
ret |= ssi_transfer(s->spi, 0x0) << (8 * i);
|
ret |= (uint64_t) ssi_transfer(s->spi, 0x0) << (8 * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
aspeed_smc_flash_unselect(fl);
|
aspeed_smc_flash_unselect(fl);
|
||||||
|
Loading…
Reference in New Issue
Block a user