diff options
author | Ulrich Ölmann <u.oelmann@pengutronix.de> | 2018-12-18 14:57:29 +0100 |
---|---|---|
committer | Roland Hieber <rhi@pengutronix.de> | 2019-01-07 12:26:49 +0100 |
commit | 02ca39f0ff1cf5bb32df1dcf744cb19a052eef7b (patch) | |
tree | b83bffabcf39714691a99449af37245d6db2b6e3 /src/barebox-state/backend_bucket_circular.c | |
parent | 97ab800e45459e9027d3000d1994c7e536b6abe7 (diff) | |
download | dt-utils-02ca39f0ff1cf5bb32df1dcf744cb19a052eef7b.tar.gz dt-utils-02ca39f0ff1cf5bb32df1dcf744cb19a052eef7b.tar.xz |
state: backend_bucket_circular: Do not leak memory
This ports the following barebox commit:
| commit af187108cf33826fd3ff2be4469563ae4169fe48
| Author: Sascha Hauer <s.hauer@pengutronix.de>
| 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 <sam@ravnborg.org>
| Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Signed-off-by: Roland Hieber <rhi@pengutronix.de>
Diffstat (limited to 'src/barebox-state/backend_bucket_circular.c')
-rw-r--r-- | src/barebox-state/backend_bucket_circular.c | 6 |
1 files 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 |