From: Zhiqiang Liu <liuzhiqian...@huawei.com>

In disassemble_map func, one pp will be allocated and stored in
pgp->paths. However, if store_path fails, pp will not be freed,
then memory leak problem occurs.

Here, we will call free_path to free pp when store_path fails.

Signed-off-by: Zhiqiang Liu <liuzhiqian...@huawei.com>
Signed-off-by: lixiaokeng <lixiaok...@huawei.com>
Signed-off-by: Martin Wilck <mwi...@suse.com>
---
 libmultipath/dmparser.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
index 25e6a4a..c103161 100644
--- a/libmultipath/dmparser.c
+++ b/libmultipath/dmparser.c
@@ -306,11 +306,15 @@ int disassemble_map(const struct _vector *pathvec,
                                        goto out1;
 
                                strlcpy(pp->dev_t, word, BLK_DEV_SIZE);
-                       }
-                       FREE(word);
 
-                       if (store_path(pgp->paths, pp))
-                               goto out;
+                               if (store_path(pgp->paths, pp)) {
+                                       free_path(pp);
+                                       goto out1;
+                               }
+                       } else if (store_path(pgp->paths, pp))
+                               goto out1;
+
+                       FREE(word);
 
                        pgp->id ^= (long)pp;
                        pp->pgindex = i + 1;
-- 
2.28.0


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

Reply via email to