[dm-devel] [multipath-tools] [patch] fix select_alias weirdness

Benjamin Marzinski bmarzins at redhat.com
Thu Jun 1 01:09:14 UTC 2006


In select_alias, the code that tries to pull the alias from dm_get_name()
sets mp->alias. So even if it fails,  mp->alias will never get set to mp->wwid. 

This patch fixes that.

-Ben
-------------- next part --------------
diff -urpN mp-devel-clean/libmultipath/propsel.c mp-devel-patched/libmultipath/propsel.c
--- mp-devel-clean/libmultipath/propsel.c	2006-05-23 11:12:15.000000000 -0500
+++ mp-devel-patched/libmultipath/propsel.c	2006-05-31 13:33:13.000000000 -0500
@@ -165,10 +165,16 @@ select_alias (struct multipath * mp)
 		if (conf->user_friendly_names)
 			mp->alias = get_user_friendly_alias(mp->wwid,
 					conf->bindings_file);
-		if (mp->alias == NULL)
-			if ((mp->alias = MALLOC(WWID_SIZE)) != NULL)
-				dm_get_name(mp->wwid, DEFAULT_TARGET,
-					    mp->alias);
+		if (mp->alias == NULL){
+			char *alias;
+			if ((alias = MALLOC(WWID_SIZE)) != NULL){
+				if (dm_get_name(mp->wwid, DEFAULT_TARGET,
+						alias) == 1)
+					mp->alias = alias;
+				else
+					FREE(alias);
+			}
+		}
 		if (mp->alias == NULL)
 			mp->alias = mp->wwid;
 	}


More information about the dm-devel mailing list