Skip to contentSkip to conversation

device-mapper ./WHATS_NEW dmsetup/dmsetup.c li ...

PATCH [email protected] 1 participant 1 message Feb 14, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/dm
Module name: device-mapper
Changes by: [email protected] 2007-02-14 15:12:16

Modified files:

	.              : WHATS_NEW 
	dmsetup        : dmsetup.c 
	lib            : libdm-report.c 

Log message:
Fix a few leaks in reporting error paths.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.171&r2=1.172
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/dmsetup/dmsetup.c.diff?cvsroot=dm&r1=1.86&r2=1.87
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-report.c.diff?cvsroot=dm&r1=1.11&r2=1.12

WHATS_NEW +1 -0
@@ -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
 ====================================
dmsetup/dmsetup.c +3 -0
@@ -2019,6 +2019,7 @@
 	if (*argc != 2) {
 		fprintf(stderr, "%s: Too few arguments\n", base);
 		_losetup_usage(stderr);
+		dm_free(device_name);
 		return 0;
 	}
 
@@ -2027,6 +2028,7 @@
 		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 @@
 	_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]++;
lib/libdm-report.c +7 -2
@@ -504,15 +504,20 @@
 
 	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)