]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Fix small memory leak
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Sun, 2 Oct 2011 19:45:41 +0000 (21:45 +0200)
committerNeilBrown <neilb@suse.de>
Sun, 2 Oct 2011 21:30:15 +0000 (08:30 +1100)
Credit goes to cppcheck.

Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
Signed-off-by: NeilBrown <neilb@suse.de>
policy.c

index 2bbbac86492d53970d29f497b381f70edc17d19e..4a6ef823a42ef336c357c92538730614955021af 100644 (file)
--- 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;
 }