mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
bootcount: Fix potential clobbering issue
When storing the single word bootcount value, apply the bootcount count mask to prevent clobbering the magic half of the value. Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
This commit is contained in:
@@ -19,7 +19,8 @@ __weak void bootcount_store(ulong a)
|
||||
uintptr_t flush_end;
|
||||
|
||||
#if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD)
|
||||
raw_bootcount_store(reg, (CONFIG_SYS_BOOTCOUNT_MAGIC & BOOTCOUNT_MAGIC_MASK) | a);
|
||||
raw_bootcount_store(reg, (CONFIG_SYS_BOOTCOUNT_MAGIC & BOOTCOUNT_MAGIC_MASK)
|
||||
| (a & BOOTCOUNT_COUNT_MASK));
|
||||
|
||||
flush_end = roundup(CONFIG_SYS_BOOTCOUNT_ADDR + 4,
|
||||
CONFIG_SYS_CACHELINE_SIZE);
|
||||
@@ -98,7 +99,8 @@ static int bootcount_mem_set(struct udevice *dev, const u32 a)
|
||||
uintptr_t flush_end;
|
||||
|
||||
if (priv->singleword) {
|
||||
raw_bootcount_store(reg, (magic & BOOTCOUNT_MAGIC_MASK) | a);
|
||||
raw_bootcount_store(reg, (magic & BOOTCOUNT_MAGIC_MASK)
|
||||
| (a & BOOTCOUNT_COUNT_MASK));
|
||||
flush_end = roundup(priv->base + 4,
|
||||
CONFIG_SYS_CACHELINE_SIZE);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user