[mdadm PATCH] Fix small memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Credit goes to cppcheck.

Signed-off-by: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
---
 policy.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/policy.c b/policy.c
index 2bbbac8..4a6ef82 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;
 }
 
-- 
1.7.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux