diff options
author | Ulrich Ölmann <u.oelmann@pengutronix.de> | 2018-12-18 14:57:57 +0100 |
---|---|---|
committer | Roland Hieber <rhi@pengutronix.de> | 2019-01-07 15:47:56 +0100 |
commit | f9d22ec87081252eaa7509b8e232116c97205110 (patch) | |
tree | 793dc1c36a1034ad2d6d5eb6c1a4365443235ad0 | |
parent | bfd82b755f32e2e54e3f27b10fb801092cb99c7c (diff) | |
download | dt-utils-f9d22ec87081252eaa7509b8e232116c97205110.tar.gz dt-utils-f9d22ec87081252eaa7509b8e232116c97205110.tar.xz |
state: backend_bucket_circular: fix memory leak
This ports the following barebox commit:
| commit 87a0df348347932a69c260d57184197a2cc24a58
| Author: Ulrich Ölmann <u.oelmann@pengutronix.de>
| Date: Mon Oct 8 19:45:23 2018 +0200
|
| 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>
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Signed-off-by: Roland Hieber <rhi@pengutronix.de>
-rw-r--r-- | src/barebox-state/backend_bucket_circular.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/barebox-state/backend_bucket_circular.c b/src/barebox-state/backend_bucket_circular.c index f71e5c2..e06debb 100644 --- a/src/barebox-state/backend_bucket_circular.c +++ b/src/barebox-state/backend_bucket_circular.c @@ -485,7 +485,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 @@ -494,7 +495,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; @@ -504,13 +505,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); |