summaryrefslogtreecommitdiffstats
path: root/common/state
diff options
context:
space:
mode:
authorUlrich Ölmann <u.oelmann@pengutronix.de>2018-10-08 19:45:23 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-10-10 07:40:40 +0200
commit87a0df348347932a69c260d57184197a2cc24a58 (patch)
treeeb9fffb3173219b9052d5829c91957f6c3acf779 /common/state
parentbf33df12725bbf2cb88596e5eaacc4e9d70ea619 (diff)
downloadbarebox-87a0df348347932a69c260d57184197a2cc24a58.tar.gz
state: backend_bucket_circular: fix memory leak
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/state')
-rw-r--r--common/state/backend_bucket_circular.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c
index 0529421..277b94d 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);