Skip to contentSkip to conversation

multipath: strdup multipath alias, so that it isn't deleted.

PATCH In review Benjamin Marzinski 2 participants 4 messages Jul 25, 2011 – Sep 1, 2011 Device mapper

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

PATCH 1/1 multipath: strdup multipath alias, so that it isn't deleted.

When a multipath device is added to multipathd with ev_add_map(), the alias is not duplicated, and is freed immediately after ev_add_map() returns, causing a memory error. This patch corrects that.

---
 libmultipath/structs_vec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
libmultipath/structs_vec.c +1 -1
index 189f25b..364e36e 100644
@@ -373,7 +373,7 @@ add_map_without_path (struct vectors * vecs, char * alias)
 	if (!mpp || !alias)
 		return NULL;
 
-	mpp->alias = alias;
+	mpp->alias = STRDUP(alias);
 
 	if (setup_multipath(vecs, mpp)) {
 		mpp->alias = NULL;
Signature · 1 line
1.7.4.4
author maintainer
#1 lore raw

Christophe, would it be possible to get this merged?

Thanks,
-Ben

Quoted 29 lines · Benjamin Marzinski

When a multipath device is added to multipathd with ev_add_map(), the alias is not duplicated, and is freed immediately after ev_add_map() returns, causing a memory error. This patch corrects that.

---
 libmultipath/structs_vec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
libmultipath/structs_vec.c +1 -1
index 189f25b..364e36e 100644
@@ -373,7 +373,7 @@ add_map_without_path (struct vectors * vecs, char * alias)
 	if (!mpp || !alias)
 		return NULL;
 
-	mpp->alias = alias;
+	mpp->alias = STRDUP(alias);
 
 	if (setup_multipath(vecs, mpp)) {
 		mpp->alias = NULL;
Signature · 6 lines
1.7.4.4

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
#2 lore raw
Quoted 5 lines · Benjamin Marzinski

When a multipath device is added to multipathd with ev_add_map(),

Quoted 1 line

the alias is not duplicated, and is freed immediately after

ev_add_map()

Quoted 2 lines

returns, causing a memory error. This patch corrects that.

Merged.

Do you think the "mpp->alias = NULL" is still necessary in the following setup_multipath() error code path ? alias is set to NULL by free_multipath() these days ...

Quoted 2 lines
      if (setup_multipath(vecs, mpp)) {
              mpp->alias = NULL;                <========
author maintainer
#3 lore raw
Quoted 12 lines · Christophe Varoqui
Quoted 5 lines · Benjamin Marzinski

When a multipath device is added to multipathd with ev_add_map(),

Quoted 1 line

the alias is not duplicated, and is freed immediately after

ev_add_map()

Quoted 2 lines

returns, causing a memory error. This patch corrects that.

Merged.

Do you think the "mpp->alias = NULL" is still necessary in the following setup_multipath() error code path ? alias is set to NULL by free_multipath() these days ...

Yeah, that looks like it can safely go.

-Ben

Quoted 2 lines
Quoted 2 lines
      if (setup_multipath(vecs, mpp)) {
              mpp->alias = NULL;                <========