]> git.baikalelectronics.ru Git - kernel.git/commit
md: fix refcount problem on mddev when stopping array.
authorNeilBrown <neilb@suse.com>
Mon, 5 Dec 2016 05:40:50 +0000 (16:40 +1100)
committerShaohua Li <shli@fb.com>
Tue, 6 Dec 2016 01:11:03 +0000 (17:11 -0800)
commit611daee3d4fda270143c111eacded9ac7a5f833a
tree580eb7ef4129964a221c3e802700cf259c0b8dce
parentf5daa9338006fe3b250dfe37e959ad7ca1588482
md: fix refcount problem on mddev when stopping array.

md_open() gets a counted reference on an mddev using mddev_find().
If it ends up returning an error, it must drop this reference.

There are two error paths where the reference is not dropped.
One only happens if the process is signalled and an awkward time,
which is quite unlikely.
The other was introduced recently in commit 8d786abfb.

Change the code to ensure the drop the reference when returning an error,
and make it harded to re-introduce this sort of bug in the future.

Reported-by: Marc Smith <marc.smith@mcc.edu>
Fixes: 8d786abfb646 ("md: changes for MD_STILL_CLOSED flag")
Signed-off-by: NeilBrown <neilb@suse.com>
Acked-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/md.c