x86: Do sanity test on the cache record in mrccache_update()
For the cache record to write in mrccache_update(), we should
perform a sanity test to see if it is a valid one.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
diff --git a/arch/x86/lib/mrccache.c b/arch/x86/lib/mrccache.c
index ec0d2cb..6dd3b5e 100644
--- a/arch/x86/lib/mrccache.c
+++ b/arch/x86/lib/mrccache.c
@@ -112,6 +112,9 @@
ulong base_addr;
int ret;
+ if (!is_mrc_cache(cur))
+ return -EINVAL;
+
/* Find the last used block */
base_addr = (1ULL << 32) - CONFIG_ROM_SIZE + entry->offset;
debug("Updating MRC cache data\n");