From 951263865603dd9b431c8625c8feefe216cf0c74 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sat, 18 Sep 2021 21:00:49 +0200 Subject: [PATCH] gcc-fanalyzer: better losetup error path Fix leaking memory on error path on _process_losetup_switches(). However real impact is close to zero as dm-loop target isn't really used. --- libdm/dm-tools/dmsetup.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c index a3d1248bc..f431f7509 100644 --- a/libdm/dm-tools/dmsetup.c +++ b/libdm/dm-tools/dmsetup.c @@ -6762,6 +6762,8 @@ static int _process_losetup_switches(const char *base, int *argcp, char ***argvp if (!_table || !_loop_table(_table, (size_t) LOOP_TABLE_SIZE, loop_file, device_name, offset)) { log_error("Could not build device-mapper table for %s.", (*argvp)[0]); + free(loop_file); + free(_table); free(device_name); return 0; } @@ -6770,6 +6772,7 @@ static int _process_losetup_switches(const char *base, int *argcp, char ***argvp _command = "create"; (*argvp)[0] = device_name ; *argcp = 1; + free(loop_file); return 1; }