multipathd: fix memory leak on error in configure
authorBenjamin Marzinski <bmarzins@redhat.com>
Tue, 9 Oct 2018 23:03:14 +0000 (18:03 -0500)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 10 Oct 2018 06:09:46 +0000 (08:09 +0200)
If configure fails after allocing mpvec, it must free it. Found by
coverity.

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

index 463b1b8..04dce04 100644 (file)
@@ -2278,7 +2278,7 @@ configure (struct vectors * vecs)
        ret = path_discovery(vecs->pathvec, DI_ALL);
        if (ret < 0) {
                condlog(0, "configure failed at path discovery");
-               return 1;
+               goto fail;
        }
 
        vector_foreach_slot (vecs->pathvec, pp, i){
@@ -2295,7 +2295,7 @@ configure (struct vectors * vecs)
        }
        if (map_discovery(vecs)) {
                condlog(0, "configure failed at map discovery");
-               return 1;
+               goto fail;
        }
 
        /*
@@ -2309,7 +2309,7 @@ configure (struct vectors * vecs)
                force_reload = FORCE_RELOAD_YES;
        if (ret) {
                condlog(0, "configure failed while coalescing paths");
-               return 1;
+               goto fail;
        }
 
        /*
@@ -2318,7 +2318,7 @@ configure (struct vectors * vecs)
         */
        if (coalesce_maps(vecs, mpvec)) {
                condlog(0, "configure failed while coalescing maps");
-               return 1;
+               goto fail;
        }
 
        dm_lib_release();
@@ -2354,6 +2354,10 @@ configure (struct vectors * vecs)
                        i--;
        }
        return 0;
+
+fail:
+       vector_free(mpvec);
+       return 1;
 }
 
 int