diff mbox

[06/39] libmultipath: memory leak in add_map_without_path()

Message ID 1466070465-1021-7-git-send-email-hare@suse.de (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show

Commit Message

Hannes Reinecke June 16, 2016, 9:47 a.m. UTC
If we call add_map_without_path() with an empty alias the
mpp structure is never freed.
Found by coverity.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/structs_vec.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index e992b54..20a7457 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -414,8 +414,12 @@  add_map_without_path (struct vectors * vecs, char * alias)
 {
 	struct multipath * mpp = alloc_multipath();
 
-	if (!mpp || !alias)
+	if (!mpp)
+		return NULL;
+	if (!alias) {
+		FREE(mpp);
 		return NULL;
+	}
 
 	mpp->alias = STRDUP(alias);