[lvm-devel] master - cleanup: add _free on error path

Zdenek Kabelac zkabelac at fedoraproject.org
Mon Nov 16 00:17:10 UTC 2015


Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5a4676fea9808f348b9bbda46c03dce298eef6e5
Commit:        5a4676fea9808f348b9bbda46c03dce298eef6e5
Parent:        c3b292a4a9924d00da421d66d8281f8cd8efc3a9
Author:        Zdenek Kabelac <zkabelac at redhat.com>
AuthorDate:    Sat Dec 6 23:55:25 2014 +0100
Committer:     Zdenek Kabelac <zkabelac at redhat.com>
CommitterDate: Mon Nov 16 01:16:11 2015 +0100

cleanup: add _free on error path

Just like with failing allocation above also _free(dev).

TODO: rework this to always use mempool and drop unneeded
comlexity we have in this function.
---
 lib/device/dev-cache.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index b9d4271..185b394 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -115,6 +115,7 @@ struct device *dev_create_file(const char *filename, struct device *dev,
 			}
 			if (!(alias->str = _strdup(filename))) {
 				log_error("filename strdup failed");
+				_free(dev);
 				return NULL;
 			}
 		}




More information about the lvm-devel mailing list