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>
This commit is contained in:
parent
2adc376c55
commit
1af95de6f0
1 changed files with 1 additions and 1 deletions
|
@ -842,7 +842,7 @@ int get_anon_bdev(dev_t *p)
|
||||||
else if (error)
|
else if (error)
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
|
||||||
if (dev == (1 << MINORBITS)) {
|
if (dev >= (1 << MINORBITS)) {
|
||||||
spin_lock(&unnamed_dev_lock);
|
spin_lock(&unnamed_dev_lock);
|
||||||
ida_remove(&unnamed_dev_ida, dev);
|
ida_remove(&unnamed_dev_ida, dev);
|
||||||
if (unnamed_dev_start > dev)
|
if (unnamed_dev_start > dev)
|
||||||
|
|
Loading…
Reference in a new issue