diff options
author | Dimitri John Ledkov <xnox@ubuntu.com> | 2019-01-15 18:40:20 +0000 |
---|---|---|
committer | Dimitri John Ledkov <xnox@ubuntu.com> | 2019-01-15 18:41:08 +0000 |
commit | ada795fa8e7b1e27c134fe7d5aedf4517cd082f5 (patch) | |
tree | 5717f98c75f6b1a9fbae50b88c35f13d07993226 /Assemble.c | |
parent | 88ee7cfa1e00aabcfc8f48b57f4b226e7b5c2158 (diff) |
New upstream release
* New upstream release
* Cherrypick patches from master up to 757e55435997e355ee9b03e5d913b5496a3c39a8.
Diffstat (limited to 'Assemble.c')
-rw-r--r-- | Assemble.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -578,6 +578,7 @@ static int load_devices(struct devs *devices, char *devmap, struct supertype *tst; int i; int dfd; + int disk_state; if (tmpdev->used != 1) continue; @@ -594,6 +595,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; } @@ -708,7 +712,9 @@ static int load_devices(struct devs *devices, char *devmap, devices[devcnt].i.disk.major = major(stb.st_rdev); devices[devcnt].i.disk.minor = minor(stb.st_rdev); - if (devices[devcnt].i.disk.state == 6) { + disk_state = devices[devcnt].i.disk.state & ~((1<<MD_DISK_FAILFAST) | + (1<<MD_DISK_WRITEMOSTLY)); + if (disk_state == ((1<<MD_DISK_ACTIVE) | (1<<MD_DISK_SYNC))) { if (most_recent < 0 || devices[devcnt].i.events > devices[most_recent].i.events) { @@ -1536,6 +1542,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; } @@ -1696,6 +1707,9 @@ try_again: else desired_state = (1<<MD_DISK_ACTIVE) | (1<<MD_DISK_SYNC); + desired_state |= devices[j].i.disk.state & ((1<<MD_DISK_FAILFAST) | + (1<<MD_DISK_WRITEMOSTLY)); + if (!devices[j].uptodate) continue; |