diff mbox

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

Message ID 20110725182700.GK15149@ether.msp.redhat.com (mailing list archive)
State Deferred, archived
Headers show

Commit Message

Benjamin Marzinski July 25, 2011, 6:27 p.m. UTC
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.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/structs_vec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Benjamin Marzinski Sept. 1, 2011, 2:45 a.m. UTC | #1
Christophe, would it be possible to get this merged?

Thanks,
-Ben

On Mon, Jul 25, 2011 at 01:27:00PM -0500, Benjamin Marzinski wrote:
> 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.
> 
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
>  libmultipath/structs_vec.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
> index 189f25b..364e36e 100644
> --- a/libmultipath/structs_vec.c
> +++ b/libmultipath/structs_vec.c
> @@ -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;
> -- 
> 1.7.4.4
> 
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
Christophe Varoqui Sept. 1, 2011, 6:55 a.m. UTC | #2
On mer., 2011-08-31 at 21:45 -0500, Benjamin Marzinski wrote:
> 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.
> > 
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 ...

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

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
Benjamin Marzinski Sept. 1, 2011, 6:30 p.m. UTC | #3
On Thu, Sep 01, 2011 at 08:55:18AM +0200, Christophe Varoqui wrote:
> On mer., 2011-08-31 at 21:45 -0500, Benjamin Marzinski wrote:
> > 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.
> > > 
> 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

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

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox

Patch

diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index 189f25b..364e36e 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -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;