From: Thomas Jarosch Date: Sun, 2 Oct 2011 19:45:41 +0000 (+0200) Subject: Fix small memory leak X-Git-Tag: mdadm-3.2.3~152 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3da7890555d8cfe17fd9ee4f5f04ab64f855919;p=thirdparty%2Fmdadm.git Fix small memory leak Credit goes to cppcheck. Signed-off-by: Thomas Jarosch Signed-off-by: NeilBrown --- diff --git a/policy.c b/policy.c index 2bbbac86..4a6ef823 100644 --- a/policy.c +++ b/policy.c @@ -757,8 +757,10 @@ int policy_check_path(struct mdinfo *disk, struct map_ent *array) snprintf(path, PATH_MAX, FAILED_SLOTS_DIR "/%s", id_path); f = fopen(path, "r"); - if (!f) + if (!f) { + free(id_path); return 0; + } rv = fscanf(f, " %s %x:%x:%x:%x\n", array->metadata, @@ -767,6 +769,7 @@ int policy_check_path(struct mdinfo *disk, struct map_ent *array) array->uuid+2, array->uuid+3); fclose(f); + free(id_path); return rv == 5; }