]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bcache: add mutex lock for bch_is_open
authorJianjian Huo <samuel.huo@gmail.com>
Sun, 13 Jul 2014 16:08:59 +0000 (09:08 -0700)
committerLuis Henriques <luis.henriques@canonical.com>
Thu, 24 Mar 2016 10:01:17 +0000 (10:01 +0000)
commit 789d21dbd9d8889e62c79ec19585fcc97e42ef07 upstream.

Since bch_is_open will iterate linked list bch_cache_sets and
uncached_devices, it needs bch_register_lock.

Signed-off-by: Jianjian Huo <samuel.huo@gmail.com>
Cc: Kamal Mostafa <kamal@canonical.com>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
drivers/md/bcache/super.c

index 72e660cafaddef62205fa13ae9003eb8bceeb48a..70db24e4194786abbc810681d01f79f9c92dd238 100644 (file)
@@ -1950,10 +1950,12 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
        if (IS_ERR(bdev)) {
                if (bdev == ERR_PTR(-EBUSY)) {
                        bdev = lookup_bdev(strim(path));
+                       mutex_lock(&bch_register_lock);
                        if (!IS_ERR(bdev) && bch_is_open(bdev))
                                err = "device already registered";
                        else
                                err = "device busy";
+                       mutex_unlock(&bch_register_lock);
                        if (attr == &ksysfs_register_quiet)
                                goto out;
                }