summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongwoo Lee <dwoo08.lee@samsung.com>2019-07-08 16:07:45 +0900
committerDongwoo Lee <dwoo08.lee@samsung.com>2019-07-08 08:27:09 +0000
commit4162a2d539e6d3a52521c3cff9b0960db5a954ca (patch)
treedbb506e2d8d9e4476835a8df1cc19821e13dc7ed
parentad730409dcecc9e34e7b5ecc2da459a43640854b (diff)
downloadinitrd-flash-accepted/tizen_5.5_unified_wearable_hotfix.tar.gz
initrd-flash-accepted/tizen_5.5_unified_wearable_hotfix.tar.bz2
initrd-flash-accepted/tizen_5.5_unified_wearable_hotfix.zip
This patch makes resources are freed on error case while scanning the type of filesystem with blkid APIs. This resource leakage was reported by static analystic tool. Change-Id: Ibeba4190316fb1db0bde02eaca0648c0db0bad2e Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
-rw-r--r--src/dfu.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/dfu.c b/src/dfu.c
index 0131e42..4edf1a1 100644
--- a/src/dfu.c
+++ b/src/dfu.c
@@ -102,7 +102,7 @@ static char *get_partition_fstype(const char *devname)
blkid_tag_iterate tag_iter;
blkid_dev dev;
blkid_cache cache = NULL;
- const char *type, *value;
+ const char *type, *value, *fstype = NULL;
int ret;
ret = blkid_get_cache(&cache, NULL);
@@ -113,29 +113,29 @@ static char *get_partition_fstype(const char *devname)
dev = blkid_get_dev(cache, devname, 0);
if (!dev)
- return NULL;
+ goto err_put_cache;
dev = blkid_verify(cache, dev);
if (!dev)
- return NULL;
+ goto err_put_cache;
tag_iter = blkid_tag_iterate_begin(dev);
while (blkid_tag_next(tag_iter, &type, &value) == 0) {
if (!strncmp(type, "TYPE", 4)) {
- char *fstype = strdup(value);
-
+ fstype = strdup(value);
if (!fstype)
- return NULL;
+ fprintf(stderr, "failed to duplicate fs type string\n");
- blkid_tag_iterate_end(tag_iter);
- blkid_put_cache(cache);
- return fstype;
+ break;
}
}
+
blkid_tag_iterate_end(tag_iter);
+
+err_put_cache:
blkid_put_cache(cache);
- return NULL;
+ return fstype;
}
static int mount_dev(const char *dev)