[dm-devel] [PATCH] multipathd: fix memory leak in reconfigure()

tang.junhui at zte.com.cn tang.junhui at zte.com.cn
Mon Jul 18 12:14:31 UTC 2016


From: "tang.junhui" <tang.junhui at zte.com.cn>

Problem:
Memory leak exists in reconfigure() when multipathd command reconfigure is executed.

Reasons:
 * The following judgment condition is not satisfied when there is no path,
   free_pathvec() is not called to free the vector of vecs->pathvec:
       if (VECTOR_SIZE(vecs->pathvec))
           free_pathvec(vecs->pathvec, FREE_PATHS);
 * Then the vecs->pathvec is set to NULL, so the vector memory which
   vecs->pathvec pointed to is leaked:
       vecs->pathvec = NULL;

Signed-off-by: tang.junhui <tang.junhui at zte.com.cn>
---
 multipathd/main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/multipathd/main.c b/multipathd/main.c
index c129298..d9731cd 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -1997,9 +1997,7 @@ reconfigure (struct vectors * vecs)
 	if (VECTOR_SIZE(vecs->mpvec))
 		remove_maps_and_stop_waiters(vecs);
 
-	if (VECTOR_SIZE(vecs->pathvec))
-		free_pathvec(vecs->pathvec, FREE_PATHS);
-
+	free_pathvec(vecs->pathvec, FREE_PATHS);
 	vecs->pathvec = NULL;
 
 	/* Re-read any timezone changes */
-- 
2.8.1.windows.1

--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail (and any attachment transmitted herewith) is privileged and confidential and is intended for the exclusive use of the addressee(s).  If you are not an intended recipient, any disclosure, reproduction, distribution or other dissemination or use of the information contained is strictly prohibited.  If you have received this mail in error, please delete it and notify us immediately.




More information about the dm-devel mailing list