From 0e7a93fa65fcc7949c02ee9ac9a19af7351ee3f0 Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Wed, 25 Jan 2017 11:00:18 -0700 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/18236 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans Reviewed-by: Paul Menzel --- src/drivers/pc80/rtc/mc146818rtc.c | 8 ++++---- 1 file 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; }