From 87a0df348347932a69c260d57184197a2cc24a58 Mon Sep 17 00:00:00 2001 From: Ulrich Ölmann Date: Mon, 8 Oct 2018 19:45:23 +0200 Subject: state: backend_bucket_circular: fix memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ulrich Ölmann Signed-off-by: Sascha Hauer --- common/state/backend_bucket_circular.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'common/state') diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c index 0529421a2c..277b94d797 100644 --- a/common/state/backend_bucket_circular.c +++ b/common/state/backend_bucket_circular.c @@ -480,7 +480,8 @@ int state_backend_bucket_circular_create(struct device_d *dev, const char *path, circ->fd = open(path, O_RDWR); if (circ->fd < 0) { pr_err("Failed to open circular bucket '%s'\n", path); - return -errno; + ret = -errno; + goto out_free; } #endif @@ -489,7 +490,7 @@ int state_backend_bucket_circular_create(struct device_d *dev, const char *path, dev_info(dev, "Not using eraseblock %u, it is marked as bad (%d)\n", circ->eraseblock, ret); ret = -EIO; - goto out_free; + goto out_close; } circ->bucket.read = state_backend_bucket_circular_read; @@ -499,13 +500,15 @@ int state_backend_bucket_circular_create(struct device_d *dev, const char *path, ret = state_backend_bucket_circular_init(*bucket); if (ret) - goto out_free; + goto out_close; return 0; -out_free: +out_close: #ifndef __BAREBOX__ close(circ->fd); +out_free: + free(circ->mtd); #endif free(circ); -- cgit v1.2.3 From f6a47cc3de70b6bc8a79b0b6dc120b2442c472c2 Mon Sep 17 00:00:00 2001 From: Ulrich Ölmann Date: Mon, 8 Oct 2018 20:02:06 +0200 Subject: common: state: fix typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ulrich Ölmann Signed-off-by: Sascha Hauer --- common/state/state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/state') diff --git a/common/state/state.c b/common/state/state.c index 25d9502111..1273c494c1 100644 --- a/common/state/state.c +++ b/common/state/state.c @@ -83,7 +83,7 @@ out: } /** - * state_load - Loads a state from the backend + * state_do_load - Loads a state from the backend * @param state The state that should be updated to contain the loaded data * @return 0 on success, -errno on failure. If no state is loaded the previous * values remain in the state. -- cgit v1.2.3 From 0d0a472821b28aa999fb8e71ff949a87cb4f27b0 Mon Sep 17 00:00:00 2001 From: Ulrich Ölmann Date: Wed, 10 Oct 2018 14:23:40 +0200 Subject: state: backend_bucket_circular: remove unused variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This has been forgotten in commit 9d6d91931afb ("state: Remove -EUCLEAN check from userspace tool"). Signed-off-by: Ulrich Ölmann Signed-off-by: Sascha Hauer --- common/state/backend_bucket_circular.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'common/state') diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c index 277b94d797..4b71d8751d 100644 --- a/common/state/backend_bucket_circular.c +++ b/common/state/backend_bucket_circular.c @@ -155,8 +155,6 @@ static int state_mtd_peb_read(struct state_backend_storage_bucket_circular *circ { int ret; off_t offset = suboffset; - struct mtd_ecc_stats stat1, stat2; - bool nostats = false; offset += (off_t)circ->eraseblock * circ->mtd->erasesize; -- cgit v1.2.3