Skip to contentSkip to conversation

LVM2/libdm libdm-common.c

PATCH [email protected] 1 participant 1 message Feb 13, 2012

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac at sourceware.org 2012-02-13 14:39:24

Modified files:
libdm : libdm-common.c

Log message:
Fix missing temp_buf init for error path

In previous commit this was missing, also deallocate in reversed order.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.137&r2=1.138

libdm/libdm-common.c +4 -4
@@ -1188,7 +1188,7 @@
 
 static int _sysfs_get_dm_name(uint32_t major, uint32_t minor, char *buf, size_t buf_size)
 {
-	char *sysfs_path, *temp_buf;
+	char *sysfs_path, *temp_buf = NULL;
 	FILE *fp = NULL;
 	int r = 0;
 	size_t len;
@@ -1232,15 +1232,15 @@
 	if (fp && fclose(fp))
 		log_sys_error("fclose", sysfs_path);
 
-	dm_free(sysfs_path);
 	dm_free(temp_buf);
+	dm_free(sysfs_path);
 
 	return r;
 }
 
 static int _sysfs_get_kernel_name(uint32_t major, uint32_t minor, char *buf, size_t buf_size)
 {
-	char *sysfs_path, *temp_buf, *name;
+	char *name, *sysfs_path, *temp_buf = NULL;
 	ssize_t size;
 	size_t len;
 	int r = 0;
@@ -1281,8 +1281,8 @@
 	strcpy(buf, name);
 	r = 1;
 bad:
-	dm_free(sysfs_path);
 	dm_free(temp_buf);
+	dm_free(sysfs_path);
 
 	return r;
 }