Skip to content

Commit

Permalink
fs:super:get_anon_bdev: fix race condition could cause dev exceed its…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
Wang YanQing authored and Al Viro committed Jul 1, 2015
1 parent 2adc376 commit 1af95de
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/super.c
Original file line number Diff line number Diff line change
@@ -842,7 +842,7 @@ int get_anon_bdev(dev_t *p)
else if (error)
return -EAGAIN;

if (dev == (1 << MINORBITS)) {
if (dev >= (1 << MINORBITS)) {
spin_lock(&unnamed_dev_lock);
ida_remove(&unnamed_dev_ida, dev);
if (unnamed_dev_start > dev)

0 comments on commit 1af95de

Please sign in to comment.