mdadm/0001-Assemble-set-devices-to-NULL-when-load_devices-can-t.patch
Zhiqiang Liu 0c2f4fd8eb mdadm: renumber patches
patches number counts from 6000. We renumber patches from 0.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
2020-06-29 22:06:27 +08:00

37 lines
972 B
Diff

From 13150f803a18df9b2feddd424bf513b8806bc7e8 Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Wed, 10 Apr 2019 21:33:29 +0800
Subject: [PATCH 2/6] Assemble: set devices to NULL when load_devices can't
load device
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
---
Assemble.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Assemble.c b/Assemble.c
index 0264190..a79466c 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.19.1