diff options
author | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2024-08-06 16:11:18 +0200 |
---|---|---|
committer | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2024-08-06 16:41:07 +0200 |
commit | 4b041873ff5556882bc6f17ac3de00c72eebcc4f (patch) | |
tree | 662cf9f51a164ad5e7cb618d75c22d89947bf104 /mdstat.c | |
parent | Grow_reshape: set only component_size for size grow (diff) | |
download | mdadm-4b041873ff5556882bc6f17ac3de00c72eebcc4f.tar.xz mdadm-4b041873ff5556882bc6f17ac3de00c72eebcc4f.zip |
mdstat: fix list detach issues
Move ent = ent->next; to while. It was outside the loop so if there
are more than 2 elements and we are looking for 3rd element it causes
infinite loop..
Fix el->next zeroing. It causes segfault in mdstat_free(). Theses
issues were not visible in my testing because I had only 2 MD devices.
Fixes: 4b3644ab4ce6 ("mdstat: Rework mdstat external arrays handling")
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Diffstat (limited to 'mdstat.c')
-rw-r--r-- | mdstat.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -123,13 +123,15 @@ static void mdstat_ent_list_detach_element(struct mdstat_ent **list_head, struct ent->next = el->next; break; } + + ent = ent->next; } - ent = ent->next; } + /* Guard if not found or list is empty - not allowed */ assert(ent); - ent->next = NULL; + el->next = NULL; } void free_mdstat(struct mdstat_ent *ms) |