Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/34373 )
Change subject: drivers/spi: Use 64 bits in multiplication ......................................................................
drivers/spi: Use 64 bits in multiplication
speed is a 64 bit variable, so use 64 bits in the intermediate calculations to avoid possible overflow.
Change-Id: Id36eda6d64057cde4750184d03c9701011edb890 Signed-off-by: Jacob Garber jgarber1@ualberta.ca Found-by: Coverity CID 1402094 --- M src/drivers/spi/cbfs_spi.c 1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/34373/1
diff --git a/src/drivers/spi/cbfs_spi.c b/src/drivers/spi/cbfs_spi.c index ad282c6..9437c2e 100644 --- a/src/drivers/spi/cbfs_spi.c +++ b/src/drivers/spi/cbfs_spi.c @@ -55,7 +55,7 @@ u64 speed; /* KiB/s */ int bps; /* Bits per second */
- speed = size * 1000 / usecs; + speed = size * 1000ULL / usecs; bps = speed * 8;
printk(BIOS_DEBUG, "read SPI %#zx %#zx: %ld us, %lld KB/s, %d.%03d Mbps\n",
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/34373 )
Change subject: drivers/spi: Use 64 bits in multiplication ......................................................................
Patch Set 1:
This was done intentionally to prevent a build error on MIPS (which doesn't support 64-bit multiplication atm). We considered that the risk of overflow here is negligible in practice (with realistic SPI speeds).
I assume you'll get a Verified-1 from Jenkins shortly.
Jacob Garber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/34373 )
Change subject: drivers/spi: Use 64 bits in multiplication ......................................................................
Patch Set 1:
Patch Set 1:
This was done intentionally to prevent a build error on MIPS (which doesn't support 64-bit multiplication atm). We considered that the risk of overflow here is negligible in practice (with realistic SPI speeds).
I assume you'll get a Verified-1 from Jenkins shortly.
Ah I see, thanks - it's only debugging code anyway
Jacob Garber has abandoned this change. ( https://review.coreboot.org/c/coreboot/+/34373 )
Change subject: drivers/spi: Use 64 bits in multiplication ......................................................................
Abandoned
MIPS does not support 64 bit multiplication right now
Jacob Garber has restored this change. ( https://review.coreboot.org/c/coreboot/+/34373 )
Change subject: drivers/spi: Use 64 bits in multiplication ......................................................................
Restored
Jacob Garber has abandoned this change. ( https://review.coreboot.org/c/coreboot/+/34373 )
Change subject: drivers/spi: Use 64 bits in multiplication ......................................................................
Abandoned
Oops, this was already fixed when MIPS was removed