[dm-devel] [PATCH 20/39] libmpathpersist: memory leak in mpath_persistent_reserve_(in, out)()

Hannes Reinecke hare at suse.de
Thu Jun 16 09:47:26 UTC 2016


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 at suse.com>
---
 libmpathpersist/mpath_persist.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index c4b8521..cfc2f0f 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -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;
 	}
 
-- 
2.6.6




More information about the dm-devel mailing list