diff options
author | Dongwoo Lee <dwoo08.lee@samsung.com> | 2019-07-08 16:07:45 +0900 |
---|---|---|
committer | Dongwoo Lee <dwoo08.lee@samsung.com> | 2019-07-08 08:27:09 +0000 |
commit | 4162a2d539e6d3a52521c3cff9b0960db5a954ca (patch) | |
tree | dbb506e2d8d9e4476835a8df1cc19821e13dc7ed | |
parent | ad730409dcecc9e34e7b5ecc2da459a43640854b (diff) | |
download | initrd-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 |
dfu: Free resources on errortizen_5.5.m2_releasesubmit/tizen_5.5_wearable_hotfix/20201026.184304submit/tizen_5.5_mobile_hotfix/20201026.185104submit/tizen_5.5/20191031.000010submit/tizen/20190708.085020accepted/tizen/unified/20190709.071054accepted/tizen/5.5/unified/wearable/hotfix/20201027.113015accepted/tizen/5.5/unified/mobile/hotfix/20201027.090327accepted/tizen/5.5/unified/20191031.004244tizen_5.5_wearable_hotfixtizen_5.5_tvtizen_5.5_mobile_hotfixtizen_5.5accepted/tizen_5.5_unified_wearable_hotfixaccepted/tizen_5.5_unified_mobile_hotfixaccepted/tizen_5.5_unified
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.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -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) |