If we call add_map_without_path() with an empty alias the
mpp structure is never freed.
Found by coverity.

Signed-off-by: Hannes Reinecke <[email protected]>
---
 libmultipath/structs_vec.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index e992b54..20a7457 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -414,8 +414,12 @@ add_map_without_path (struct vectors * vecs, char * alias)
 {
        struct multipath * mpp = alloc_multipath();
 
-       if (!mpp || !alias)
+       if (!mpp)
+               return NULL;
+       if (!alias) {
+               FREE(mpp);
                return NULL;
+       }
 
        mpp->alias = STRDUP(alias);
 
-- 
2.6.6

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

Reply via email to