From: Wang YanQing Date: Tue, 23 Jun 2015 10:54:45 +0000 (+0800) Subject: fs:super:get_anon_bdev: fix race condition could cause dev exceed its upper limitation X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=1af95de6f0119d5bde02d3a811a9f3a3661e954e;p=deliverable%2Flinux.git 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 Signed-off-by: Al Viro --- 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) 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)