From: Karel Zak Date: Mon, 13 Jan 2025 10:26:06 +0000 (+0100) Subject: libblkid: fix potential memory leaks X-Git-Tag: v2.42-start~92^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dfe1c4bc742ed3f53c06bb232ebc1f5fadd0881e;p=thirdparty%2Futil-linux.git libblkid: fix potential memory leaks Addresses: https://github.com/util-linux/util-linux/pull/3356 Signed-off-by: Karel Zak --- diff --git a/libblkid/src/save.c b/libblkid/src/save.c index 1a617c072..295924e15 100644 --- a/libblkid/src/save.c +++ b/libblkid/src/save.c @@ -109,7 +109,8 @@ int blkid_flush_cache(blkid_cache cache) && errno != EEXIST) { DBG(SAVE, ul_debug("can't create %s directory for cache file", BLKID_RUNTIME_DIR)); - return 0; + ret = 0; + goto done; } } @@ -117,7 +118,8 @@ int blkid_flush_cache(blkid_cache cache) if (((ret = stat(filename, &st)) < 0 && errno != ENOENT) || (ret == 0 && access(filename, W_OK) < 0)) { DBG(SAVE, ul_debug("can't write to cache file %s", filename)); - return 0; + ret = 0; + goto done; } /* @@ -154,7 +156,7 @@ int blkid_flush_cache(blkid_cache cache) if (!file) { ret = errno; - goto errout; + goto done; } list_for_each(p, &cache->bic_devs) { @@ -201,7 +203,7 @@ int blkid_flush_cache(blkid_cache cache) } } -errout: +done: free(tmp); if (filename != cache->bic_filename) free(filename);