diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index f7a5c0846..48398e63a 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.19 - ==================================== + Fix a few leaks in reporting error paths. [1.02.15+] Version 1.02.18 - 13th February 2007 ==================================== diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c index ebdda8f05..18c619214 100644 --- a/libdm/libdm-report.c +++ b/libdm/libdm-report.c @@ -504,15 +504,20 @@ struct dm_report *dm_report_init(uint32_t *report_types, if (!(rh->mem = dm_pool_create("report", 10 * 1024))) { log_error("dm_report_init: allocation of memory pool failed"); + dm_free(rh); return NULL; } /* Generate list of fields for output based on format string & flags */ - if (!_parse_options(rh, output_fields)) + if (!_parse_options(rh, output_fields)) { + dm_report_free(rh); return NULL; + } - if (!_parse_keys(rh, sort_keys)) + if (!_parse_keys(rh, sort_keys)) { + dm_report_free(rh); return NULL; + } /* Return updated types value for further compatility check by caller */ if (report_types) diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 09bdf4dbd..55da79a92 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -2019,6 +2019,7 @@ static int _process_losetup_switches(const char *base, int *argc, char ***argv) if (*argc != 2) { fprintf(stderr, "%s: Too few arguments\n", base); _losetup_usage(stderr); + dm_free(device_name); return 0; } @@ -2027,6 +2028,7 @@ static int _process_losetup_switches(const char *base, int *argc, char ***argv) fprintf(stderr, "%s: Could not parse loop file name %s\n", base, (*argv)[1]); _losetup_usage(stderr); + dm_free(device_name); return 0; } @@ -2034,6 +2036,7 @@ static int _process_losetup_switches(const char *base, int *argc, char ***argv) _table = dm_malloc(LOOP_TABLE_SIZE); if (!_loop_table(_table, LOOP_TABLE_SIZE, loop_file, device_name, offset)) { fprintf(stderr, "Could not build device-mapper table for %s\n", (*argv)[0]); + dm_free(device_name); return 0; } _switches[TABLE_ARG]++;