From 7c60068b2345a79ab5c12f1484c50fca6006d59f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Fri, 1 Jul 2022 18:50:26 +0300 Subject: mb/qemu-i440fx,soc/nvidia: Fix coverity reported defects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In reality the expression should not overflow as the value fits in 32 bits. Change-Id: I50d83dce25a4d464e1c979502c290d8ecd733018 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/65613 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner --- src/mainboard/emulation/qemu-i440fx/northbridge.c | 4 ++-- src/soc/nvidia/tegra124/soc.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mainboard/emulation/qemu-i440fx/northbridge.c b/src/mainboard/emulation/qemu-i440fx/northbridge.c index 96a234e580..07f345af4d 100644 --- a/src/mainboard/emulation/qemu-i440fx/northbridge.c +++ b/src/mainboard/emulation/qemu-i440fx/northbridge.c @@ -47,7 +47,7 @@ static void cpu_pci_domain_read_resources(struct device *dev) int i440fx = (nbid == 0x1237); int q35 = (nbid == 0x29c0); struct resource *res; - unsigned long tomk = 0; + uint64_t tomk = 0; int idx = 10; FWCfgFile f; @@ -93,7 +93,7 @@ static void cpu_pci_domain_read_resources(struct device *dev) /* qemu older than 1.7, or reading etc/e820 failed. Fallback to cmos. */ tomk = qemu_get_memory_size(); uint64_t high = qemu_get_high_memory_size(); - printk(BIOS_DEBUG, "QEMU: cmos: %lu MiB RAM below 4G.\n", tomk / 1024); + printk(BIOS_DEBUG, "QEMU: cmos: %llu MiB RAM below 4G.\n", tomk / 1024); printk(BIOS_DEBUG, "QEMU: cmos: %llu MiB RAM above 4G.\n", high / 1024); /* Report the memory regions. */ diff --git a/src/soc/nvidia/tegra124/soc.c b/src/soc/nvidia/tegra124/soc.c index 95f62a3545..64fb8681ce 100644 --- a/src/soc/nvidia/tegra124/soc.c +++ b/src/soc/nvidia/tegra124/soc.c @@ -16,13 +16,13 @@ */ static void soc_read_resources(struct device *dev) { - u32 lcdbase = fb_base_mb(); - unsigned long fb_size = FB_SIZE_MB; + uint64_t lcdbase = fb_base_mb(); + uint64_t fb_size = FB_SIZE_MB; ram_from_to(dev, 0, (uintptr_t)_dram, (sdram_max_addressable_mb() - fb_size) * MiB); mmio_range(dev, 1, lcdbase * MiB, fb_size * MiB); - ram_from_to(dev, 2, sdram_max_addressable_mb() * MiB, + ram_from_to(dev, 2, sdram_max_addressable_mb() * (uint64_t)MiB, (uintptr_t)_dram + sdram_size_mb() * (uint64_t)MiB); } -- cgit v1.2.3