diff options
author | Wang YanQing <udknight@gmail.com> | 2015-06-23 06:54:45 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-07-01 01:50:06 -0400 |
commit | 1af95de6f0119d5bde02d3a811a9f3a3661e954e (patch) | |
tree | 703a419f2f4c0203683b9030450d54bfaf1f76d8 /fs/super.c | |
parent | 2adc376c551943a07170cbe70f43e6d6065f8906 (diff) |
fs:super:get_anon_bdev: fix race condition could cause dev exceed its upper limitation
Execution of get_anon_bdev concurrently and preemptive kernel all
could bring race condition, it isn't enough to check dev against
its upper limitation with equality operator only.
This patch fix it.
Signed-off-by: Wang YanQing <udknight@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/super.c')
-rw-r--r-- | fs/super.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/super.c b/fs/super.c index 928c20f47af9..b61372354f2b 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -842,7 +842,7 @@ int get_anon_bdev(dev_t *p) | |||
842 | else if (error) | 842 | else if (error) |
843 | return -EAGAIN; | 843 | return -EAGAIN; |
844 | 844 | ||
845 | if (dev == (1 << MINORBITS)) { | 845 | if (dev >= (1 << MINORBITS)) { |
846 | spin_lock(&unnamed_dev_lock); | 846 | spin_lock(&unnamed_dev_lock); |
847 | ida_remove(&unnamed_dev_ida, dev); | 847 | ida_remove(&unnamed_dev_ida, dev); |
848 | if (unnamed_dev_start > dev) | 848 | if (unnamed_dev_start > dev) |