libmpathpersist: memory leak in mpath_persistent_reserve_(in,out)()
authorHannes Reinecke <hare@suse.de>
Wed, 15 Jun 2016 09:25:37 +0000 (11:25 +0200)
committerHannes Reinecke <hare@suse.de>
Thu, 16 Jun 2016 08:52:08 +0000 (10:52 +0200)
When either curmp or pathvec couldn't be allocated we never
free up the other one, too.
Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
libmpathpersist/mpath_persist.c

index c4b8521..cfc2f0f 100644 (file)
@@ -195,6 +195,10 @@ int mpath_persistent_reserve_in (int fd, int rq_servact,
        if (!curmp || !pathvec){
                condlog (0, "%s: vector allocation failed.", alias);
                ret = MPATH_PR_DMMP_ERROR;
+               if (curmp)
+                       vector_free(curmp);
+               if (pathvec)
+                       vector_free(pathvec);
                goto out;
        }
 
@@ -285,6 +289,10 @@ int mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope,
        if (!curmp || !pathvec){
                condlog (0, "%s: vector allocation failed.", alias);
                ret = MPATH_PR_DMMP_ERROR;
+               if (curmp)
+                       vector_free(curmp);
+               if (pathvec)
+                       vector_free(pathvec);
                goto out;
        }