diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 7726d0347..b4be42bac 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.06 - ============================= + Fix leaks in error paths found by coverity. Increase dmsetup line buffer to 4k. Version 1.02.05 - 19 Apr 2006 diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c index 0b2e3c24a..71b11ff6d 100644 --- a/libdm/libdm-common.c +++ b/libdm/libdm-common.c @@ -101,8 +101,10 @@ struct dm_task *dm_task_create(int type) return NULL; } - if (!dm_check_version()) + if (!dm_check_version()) { + dm_free(dmt); return NULL; + } memset(dmt, 0, sizeof(*dmt)); diff --git a/libdm/libdm-file.c b/libdm/libdm-file.c index dbbca5999..54c38b4e8 100644 --- a/libdm/libdm-file.c +++ b/libdm/libdm-file.c @@ -23,7 +23,7 @@ static int _create_dir_recursive(const char *dir) { char *orig, *s; - int rc; + int rc, r = 0; log_verbose("Creating directory \"%s\"", dir); /* Create parent directories */ @@ -35,22 +35,24 @@ static int _create_dir_recursive(const char *dir) if (rc < 0 && errno != EEXIST) { log_error("%s: mkdir failed: %s", orig, strerror(errno)); - dm_free(orig); - return 0; + goto out; } } *s++ = '/'; } - dm_free(orig); /* Create final directory */ rc = mkdir(dir, 0777); if (rc < 0 && errno != EEXIST) { log_error("%s: mkdir failed: %s", orig, strerror(errno)); - return 0; + goto out; } - return 1; + + r = 1; +out: + dm_free(orig); + return r; } int create_dir(const char *dir)