summaryrefslogtreecommitdiff
path: root/common/new_nvmem.c
diff options
context:
space:
mode:
authorAndrey Pronin <apronin@chromium.org>2019-09-27 15:17:15 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-01 06:18:38 +0000
commitf5afc5c7773123e397161c7decc03aeaf38b26f6 (patch)
treeb1348d69d392db4793a079f5d583e90658f7332b /common/new_nvmem.c
parent4805196e894a73a2a1285f1cd622d160ad248f77 (diff)
downloadchrome-ec-f5afc5c7773123e397161c7decc03aeaf38b26f6.tar.gz
cr50: nvmem: release var buf in setvar overflow case
Before this CL, if overflow condition was detected for an existing variable, the buffer allocated by find_var() was not released. This CL fixes this issue. BRANCH=none BUG=b:141774483 TEST=running test_nvmem with CL:1828184 applied doesn't lead to memory leaks. Change-Id: Ie09561232a613fb1f90f9a9456af73106ceb44ff Signed-off-by: Andrey Pronin <apronin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1829291 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Jason Clinton <jclinton@chromium.org>
Diffstat (limited to 'common/new_nvmem.c')
-rw-r--r--common/new_nvmem.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/common/new_nvmem.c b/common/new_nvmem.c
index fee15a3fc0..e61021e3c3 100644
--- a/common/new_nvmem.c
+++ b/common/new_nvmem.c
@@ -2934,8 +2934,10 @@ 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_BODY_SPACE)) {
+ shared_mem_release(vc);
return EC_ERROR_OVERFLOW;
+ }
/* Save the new instance first with the larger generation number. */
vc->c_header.generation++;