On 08/20/2018 10:28 AM, Guoqing Jiang wrote:
On 08/17/2018 08:08 PM, Tkaczyk, Mariusz wrote:
Hi,
After this patch I found "double free or corruption".
Scenario:
mdadm -CR /dev/md/vol -l0 -e 1.2 -n2 /dev/sd[b-c] --assume-clean
mdadm -Ss
mdadm -A /dev/md127 /dev/sd[b-c] --update metadata
*** Error in `mdadm': double free or corruption (!prev):
Could you try below changes?
diff --git a/Assemble.c b/Assemble.c
index 23892a3720ac..9d0bc1000f96 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1536,6 +1536,11 @@ try_again:
&most_recent, &bestcnt, &best, inargv);
if (devcnt < 0) {
mdfd = -3;
+ /*
+ * devices is already freed in load_devices, so set
devices
+ * to NULL to avoid double free devices.
+ */
+ devices = NULL;
goto out;
}
Maybe we need to clean these resources as well in below case.
@@ -594,6 +594,9 @@ static int load_devices(struct devs *devices, char
*devmap,
if (strcmp(c->update, "ppl") == 0 &&
ident->bitmap_fd >= 0) {
pr_err("PPL is not compatible with
bitmap\n");
+ close(mdfd);
+ free(devices);
+ free(devmap);
return -1;
}
Thanks,
Guoqing