[dm- devel][PATCH] libmultipath: fix a memory leak in dm_get_maps

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

 



In dm_get_maps func, if vector_alloc_slot(mp) fails, the
mpp should be free.

Here we call free_multipath(mpp, KEEP_PATHS) to free map.

Signed-off-by: Lixiaokeng <lixiaokeng@xxxxxxxxxx>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@xxxxxxxxxx>

---
 libmultipath/devmapper.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index f597ff8b..92eef6f1 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -1198,8 +1198,10 @@ dm_get_maps (vector mp)
 		if (!mpp)
 			goto out;

-		if (!vector_alloc_slot(mp))
+		if (!vector_alloc_slot(mp)) {
+			free_multipath(mpp, KEEP_PATHS);
 			goto out;
+		}

 		vector_set_slot(mp, mpp);
 		mpp = NULL;
-- 

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux