libmultipath: fix double free in pgpolicyfn error paths
authorBenjamin Marzinski <bmarzins@redhat.com>
Fri, 23 Aug 2019 17:48:50 +0000 (12:48 -0500)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 1 Oct 2019 19:58:30 +0000 (21:58 +0200)
commit9a6c4e8920a9f08c131120205992cf638082f947
tree454025f073274900bb37063bf9c4e81df30a50d0
parentca3826a18e86ca18a4080208dfe2676d8d6d1f2f
libmultipath: fix double free in pgpolicyfn error paths

In the pgpolicy functions, if an error is encountered after
alloc_pathgroup() is called, but before the path group is added to a
multipath device with add_pathgroup(), the pathgroup needs to be cleaned
up by calling free_pathgroup(). However, after the pathgroup has been
added to the multipath device, calling free_pgvec() will clean it up. In
this case, if free_pathgroup() is called first, the recently added
pathgroup will be freed twice.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
libmultipath/pgpolicies.c