libmultipath: fix a memory leak in dm_get_maps
PATCH 1/1 libmultipath: fix a memory leak in dm_get_maps
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 <[email protected]>
Signed-off-by Zhiqiang Liu <[email protected]>
--- libmultipath/devmapper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
libmultipath/devmapper.c +3 -1
@@ -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 ;
Quoted 7 lines · lixiaokeng
In
dm_get_mapsfunc, ifvector_alloc_slot(mp)fails, the mpp should be free.Here we call
free_multipath(mpp, KEEP_PATHS)to free map.Signed-off-by Lixiaokeng <[email protected]>Signed-off-by Zhiqiang Liu <[email protected]>
Reviewed-by Benjamin Marzinski <[email protected]>
Quoted 22 lines
--- libmultipath/devmapper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)libmultipath/devmapper.c +3
-1@@ -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 ;