diff options
author | Guoqing Jiang <gqjiang@suse.com> | 2018-08-27 05:10:52 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2018-09-27 16:30:19 +0200 |
commit | 783a4a93b9f01d1e9de98ea7d318a7885382cefa (patch) | |
tree | 1e58e21c85caa98555b897110319dd4f690bc3be /Assemble.c | |
parent | Assemble: free resources in load_devices (diff) | |
download | mdadm-783a4a93b9f01d1e9de98ea7d318a7885382cefa.tar.xz mdadm-783a4a93b9f01d1e9de98ea7d318a7885382cefa.zip |
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
Reported-by: Tkaczyk Mariusz <mariusz.tkaczyk@intel.com>
Tested-by: Tkaczyk Mariusz <mariusz.tkaczyk@intel.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'Assemble.c')
-rw-r--r-- | Assemble.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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; } |