libmultipath: fix null dereference int alloc_path_group
authorBenjamin Marzinski <bmarzins@redhat.com>
Tue, 9 Oct 2018 23:03:08 +0000 (18:03 -0500)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 10 Oct 2018 06:09:37 +0000 (08:09 +0200)
If all_pathgroup failed to allocate a vector for pgp->paths, instead of
failing after it freed pgp, it would set pgp to NULL and then
dereference it. This patch fixes that. Found by coverity.

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

index ae847d6..caa178a 100644 (file)
@@ -165,7 +165,7 @@ alloc_pathgroup (void)
 
        if (!pgp->paths) {
                FREE(pgp);
-               pgp = NULL;
+               return NULL;
        }
 
        dm_pathgroup_to_gen(pgp)->ops = &dm_gen_pathgroup_ops;