fs:super:get_anon_bdev: fix race condition could cause dev exceed its upper limitation
authorWang YanQing <udknight@gmail.com>
Tue, 23 Jun 2015 10:54:45 +0000 (18:54 +0800)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 1 Jul 2015 05:50:06 +0000 (01:50 -0400)
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>
fs/super.c

index 928c20f47af9c1e26906e7e3be7dfa7705e8ca15..b61372354f2bd1cd104d140003859a4333456c79 100644 (file)
@@ -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)
This page took 0.024922 seconds and 5 git commands to generate.