Since load_devices frees "devices" when it can't find any device, we should set it to NULL to avoid double free issue which can be reproduced by below steps: 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 Reported-by: Tkaczyk Mariusz <mariusz.tkaczyk@xxxxxxxxx> Tested-by: Tkaczyk Mariusz <mariusz.tkaczyk@xxxxxxxxx> Signed-off-by: Guoqing Jiang <gqjiang@xxxxxxxx> --- Assemble.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assemble.c b/Assemble.c index 02641900420c..a79466c6cf0c 100644 --- a/Assemble.c +++ b/Assemble.c @@ -1539,6 +1539,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; } -- 2.13.6