diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2017-04-19 10:13:58 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-04-19 10:14:00 +0200 |
commit | af187108cf33826fd3ff2be4469563ae4169fe48 (patch) | |
tree | 61c8a6248fa53cb85d05416834d6dc427b837ca7 | |
parent | dec7b4d2bf9c94a4760413a79d885842db902b65 (diff) | |
download | barebox-af187108cf33826fd3ff2be4469563ae4169fe48.tar.gz barebox-af187108cf33826fd3ff2be4469563ae4169fe48.tar.xz |
state: backend_bucket_circular: Do not leak memory
buf was just allocated, free it before returning an error.
Reported-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | common/state/backend_bucket_circular.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c index 5279ec9ce2..832f44e599 100644 --- a/common/state/backend_bucket_circular.c +++ b/common/state/backend_bucket_circular.c @@ -385,7 +385,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) { @@ -408,9 +408,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 |