[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[dm-devel] [PATCH] Substantial memory leak when large amount of LUNs are present.



From: Konrad Rzeszutek <konrad mars virtualiron com>

 dm_get_name() was creating a vector, populating it with multipaths,
 then only deleting the vector itself, which leaked all of the multipaths.
 If the number of LUNs (ie. multipaths) was large then the leak was equally large.

Signed-off-by: Konrad Rzeszutek <konrad virtualiron com>
---
 libmultipath/devmapper.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 70e10c2..a021e44 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -764,7 +764,7 @@ dm_get_name(char *uuid, char *name)
 {
 	vector vec;
 	struct multipath *mpp;
-	int i;
+	int i, rc = 0;
 
 	vec = vector_alloc();
 
@@ -772,20 +772,22 @@ dm_get_name(char *uuid, char *name)
 		return 0;
 
 	if (dm_get_maps(vec)) {
-		vector_free(vec);
-		return 0;
+		goto out;
 	}
 
 	vector_foreach_slot(vec, mpp, i) {
 		if (!strcmp(uuid, mpp->wwid)) {
-			vector_free(vec);
 			strcpy(name, mpp->alias);
-			return 1;
+			rc=1;
+			break;
 		}
 	}
-
+out:
+	vector_foreach_slot(vec, mpp, i) {
+		free_multipath(mpp, KEEP_PATHS);
+	}
 	vector_free(vec);
-	return 0;
+	return rc;
 }
 
 int
-- 
1.5.4.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]