summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2018-08-30 10:36:48 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-09-04 16:53:45 -0700
commitba968e1782979aabc4af5cf758d601d9dd4e1112 (patch)
tree56d08f32b99a4b2f9e9a6eeedd6cbe0458e66d32
parent16839242bf1309feabbdc4ba52d4b19ede8dbd0a (diff)
downloadchrome-ec-ba968e1782979aabc4af5cf758d601d9dd4e1112.tar.gz
cbi: fail set command early if WP is asserted
We are changing the in-memory version of CBI but cannot write it out to the EEPROM. This causes weird behavior when reading the CBI setting out again because it does not match the EEPROM values BRANCH=none BUG=b:113577856 TEST=Values aren't written to CBI in-memory when WP is asserted. Change-Id: Ie74fd3e47b3fabe6436e2787931b7238a112ec94 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1196846 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--common/cbi.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/common/cbi.c b/common/cbi.c
index 3a686085c5..3fc199bc67 100644
--- a/common/cbi.c
+++ b/common/cbi.c
@@ -258,7 +258,15 @@ DECLARE_HOST_COMMAND(EC_CMD_GET_CROS_BOARD_INFO,
static int hc_cbi_set(struct host_cmd_handler_args *args)
{
const struct __ec_align4 ec_params_set_cbi *p = args->params;
- int rv;
+
+ /*
+ * If we ultimately cannot write to the flash, then fail early unless
+ * we are explicitly trying to write to the in-memory CBI only
+ */
+ if (eeprom_is_write_protected() && !(p->flag & CBI_SET_NO_SYNC)) {
+ CPRINTS("Failed to write for WP");
+ return EC_RES_ACCESS_DENIED;
+ }
#ifndef CONFIG_SYSTEM_UNLOCKED
/* These fields are not allowed to be reprogrammed regardless the
@@ -290,10 +298,9 @@ static int hc_cbi_set(struct host_cmd_handler_args *args)
if (p->flag & CBI_SET_NO_SYNC)
return EC_RES_SUCCESS;
- rv = write_board_info();
- if (rv)
- return (rv == EC_ERROR_ACCESS_DENIED) ?
- EC_RES_ACCESS_DENIED : EC_RES_ERROR;
+ /* We already checked write protect failure case. */
+ if (write_board_info())
+ return EC_RES_ERROR;
return EC_RES_SUCCESS;
}