From 831d113c640edbc2a63cd03436a840b0688beab8 Mon Sep 17 00:00:00 2001 From: Andrey Pronin Date: Fri, 27 Sep 2019 15:27:37 -0700 Subject: cr50: nvmem: fix total vars overflow check Before this CL, when changing an already existing variable, setvar_() was ensuring that the new size of *all* variables is smaller than the limit for one variable. This CL fixes the check: now it checks that the new size of all variables is smaller than the total variables size limit. BRANCH=none BUG=b:141774726 TEST=running test_nvmem with CL:1828184 applied doesn't lead to overflows in setvar. Change-Id: Icc70d728a2d6986d98b686980081e1cbba132195 Signed-off-by: Andrey Pronin Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1829292 Reviewed-by: Vadim Bendebury Commit-Queue: Jason Clinton --- common/new_nvmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/new_nvmem.c b/common/new_nvmem.c index e61021e3c3..58b9b46117 100644 --- a/common/new_nvmem.c +++ b/common/new_nvmem.c @@ -2934,7 +2934,7 @@ static int setvar_(const uint8_t *key, uint8_t key_len, const uint8_t *val, if ((old_var_space < new_var_space) && ((total_var_space + new_var_space - old_var_space) > - MAX_VAR_BODY_SPACE)) { + MAX_VAR_TOTAL_SPACE)) { shared_mem_release(vc); return EC_ERROR_OVERFLOW; } -- cgit v1.2.1