diff options
author | Nico Huber <nico.h@gmx.de> | 2024-01-14 14:26:37 +0100 |
---|---|---|
committer | Julius Werner <jwerner@chromium.org> | 2024-08-23 01:08:16 +0000 |
commit | 41feb32559d574e7e08f42742dc4ef8abc3ddd46 (patch) | |
tree | 3ebbce83ef7805f80c94240d9cde356cf944694a /src/drivers/spi | |
parent | 7bb8de184338453cde924c816e027af5eae40d32 (diff) |
region: Turn region_end() into an inclusive region_last()
The current region_end() implementation is susceptible to overflow
if the region is at the end of the addressable space. A common case
with the memory-mapped flash of x86 directly below the 32-bit limit.
Note: This patch also changes console output to inclusive limits.
IMO, to the better.
Change-Id: Ic4bd6eced638745b7e845504da74542e4220554a
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/79946
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/drivers/spi')
-rw-r--r-- | src/drivers/spi/winbond.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/drivers/spi/winbond.c b/src/drivers/spi/winbond.c index 3426d08e70..db93ff616c 100644 --- a/src/drivers/spi/winbond.c +++ b/src/drivers/spi/winbond.c @@ -374,7 +374,7 @@ static int winbond_get_write_protection(const struct spi_flash *flash, } printk(BIOS_DEBUG, "WINBOND: flash protected range 0x%08zx-0x%08zx\n", - region_offset(&wp_region), region_end(&wp_region)); + region_offset(&wp_region), region_last(&wp_region)); return region_is_subregion(&wp_region, region); } @@ -502,7 +502,7 @@ winbond_set_write_protection(const struct spi_flash *flash, int ret; /* Need to touch TOP or BOTTOM */ - if (region_offset(region) != 0 && region_end(region) != flash->size) + if (region_offset(region) != 0 && region_last(region) != flash->size - 1) return -1; params = flash->part; @@ -600,7 +600,7 @@ winbond_set_write_protection(const struct spi_flash *flash, return ret; printk(BIOS_DEBUG, "WINBOND: write-protection set to range " - "0x%08zx-0x%08zx\n", region_offset(region), region_end(region)); + "0x%08zx-0x%08zx\n", region_offset(region), region_last(region)); return ret; } |