From: Martin Schwenke Date: Wed, 3 Jul 2019 10:40:44 +0000 (+1000) Subject: ctdb-utils: CID 1273087 - Resource leak X-Git-Tag: talloc-2.3.1~837 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=597039daeb88f6d97f71ecaaa55efd7e091638ea;p=thirdparty%2Fsamba.git ctdb-utils: CID 1273087 - Resource leak Ensure that p is not leaked. This is a test program and the program exits anyway. No need to backport. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/utils/ping_pong/ping_pong.c b/ctdb/utils/ping_pong/ping_pong.c index 2b337faaf55..3d28f34982d 100644 --- a/ctdb/utils/ping_pong/ping_pong.c +++ b/ctdb/utils/ping_pong/ping_pong.c @@ -153,8 +153,7 @@ static void ping_pong(int fd, int num_locks) ret = lock_range(fd, 0, 1, true); if (ret != 0) { printf("initial lock at 0 failed! - %s\n", strerror(errno)); - free(val); - return; + goto done; } i = 0; @@ -167,8 +166,7 @@ static void ping_pong(int fd, int num_locks) if (do_check) { ret = check_lock(fd, i, 1); if (ret != 0) { - free(val); - return; + goto done; } } if (do_reads) { @@ -209,6 +207,12 @@ static void ping_pong(int fd, int num_locks) } loops++; } + +done: + if (use_mmap) { + munmap(p, num_locks+1); + } + free(val); } static void usage(void)