Skip to contentSkip to conversation

fix select_alias weirdness

PATCH In review Benjamin Marzinski 2 participants 2 messages Jun 1, 2006 Device mapper

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

PATCH 1/1 fix select_alias weirdness

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

libmultipath/propsel.c +10 -4
diff -urpN mp-devel-clean/libmultipath/propsel.c mp-devel-patched/libmultipath/propsel.c
@@ -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;
 	}
#1 lore raw
Quoted 5 lines · Benjamin Marzinski

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.

Right. Applied.

Regards,
cvaroqui