From 02ca39f0ff1cf5bb32df1dcf744cb19a052eef7b Mon Sep 17 00:00:00 2001 From: Ulrich Ölmann Date: Tue, 18 Dec 2018 14:57:29 +0100 Subject: state: backend_bucket_circular: Do not leak memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ports the following barebox commit: | commit af187108cf33826fd3ff2be4469563ae4169fe48 | Author: Sascha Hauer | Date: Wed Apr 19 10:13:58 2017 +0200 | | state: backend_bucket_circular: Do not leak memory | | buf was just allocated, free it before returning an error. | | Reported-by: Sam Ravnborg | Signed-off-by: Sascha Hauer Signed-off-by: Ulrich Ölmann Signed-off-by: Roland Hieber --- src/barebox-state/backend_bucket_circular.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/barebox-state/backend_bucket_circular.c b/src/barebox-state/backend_bucket_circular.c index 9caa994..d573d52 100644 --- a/src/barebox-state/backend_bucket_circular.c +++ b/src/barebox-state/backend_bucket_circular.c @@ -386,7 +386,7 @@ static int state_backend_bucket_circular_init( ret = state_mtd_peb_read(circ, buf, 0, circ->max_size); if (ret && ret != -EUCLEAN) - return ret; + goto out; for (sub_offset = circ->max_size - circ->writesize; sub_offset >= 0; sub_offset -= circ->writesize) { @@ -409,9 +409,11 @@ static int state_backend_bucket_circular_init( circ->write_area = sub_offset + circ->writesize; circ->last_written_length = written_length; + ret = 0; +out: free(buf); - return 0; + return ret; } static void state_backend_bucket_circular_free(struct -- cgit v1.2.3