summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Roth <martinroth@google.com>2017-01-25 11:00:18 -0700
committerNico Huber <nico.h@gmx.de>2017-01-26 23:49:44 +0100
commit0e7a93fa65fcc7949c02ee9ac9a19af7351ee3f0 (patch)
tree709b32aec14f169e5f4b142909dcc0f62747c77a /src
parent011792415963e19dfe84da25cd3ab1f31bd55b34 (diff)
drivers/pc80/rtc: Check cmos checksum BEFORE reading cmos value
If cmos is invalid, it doesn't make sense to read the value before finding that out. Change-Id: Ieb4661aad7e4d640772325c3c6b184de1947edc3 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/18236 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Diffstat (limited to 'src')
-rw-r--r--src/drivers/pc80/rtc/mc146818rtc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/drivers/pc80/rtc/mc146818rtc.c b/src/drivers/pc80/rtc/mc146818rtc.c
index 0d36b004a6..a102917d8d 100644
--- a/src/drivers/pc80/rtc/mc146818rtc.c
+++ b/src/drivers/pc80/rtc/mc146818rtc.c
@@ -251,14 +251,14 @@ enum cb_err get_option(void *dest, const char *name)
return CB_CMOS_OPTION_NOT_FOUND;
}
- if (get_cmos_value(ce->bit, ce->length, dest) != CB_SUCCESS) {
- UNLOCK_NVRAM_CBFS_SPINLOCK();
- return CB_CMOS_ACCESS_ERROR;
- }
if (!cmos_checksum_valid(LB_CKS_RANGE_START, LB_CKS_RANGE_END, LB_CKS_LOC)) {
UNLOCK_NVRAM_CBFS_SPINLOCK();
return CB_CMOS_CHECKSUM_INVALID;
}
+ if (get_cmos_value(ce->bit, ce->length, dest) != CB_SUCCESS) {
+ UNLOCK_NVRAM_CBFS_SPINLOCK();
+ return CB_CMOS_ACCESS_ERROR;
+ }
UNLOCK_NVRAM_CBFS_SPINLOCK();
return CB_SUCCESS;
}