]> git.itanic.dy.fi Git - linux-stable/commitdiff
bcache: Fix leak of bdev reference
authorJan Kara <jack@suse.cz>
Wed, 6 Sep 2017 06:25:51 +0000 (14:25 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Sep 2017 09:00:16 +0000 (11:00 +0200)
commit 4b758df21ee7081ab41448d21d60367efaa625b3 upstream.

If blkdev_get_by_path() in register_bcache() fails, we try to lookup the
block device using lookup_bdev() to detect which situation we are in to
properly report error. However we never drop the reference returned to
us from lookup_bdev(). Fix that.

Signed-off-by: Jan Kara <jack@suse.cz>
Acked-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/bcache/super.c

index 5bf9da324b78c4f085b418bffb85b93076131121..46f4c7ee5560d9336f19e66fb3b85bbdd654d596 100644 (file)
@@ -1960,6 +1960,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
                        else
                                err = "device busy";
                        mutex_unlock(&bch_register_lock);
+                       if (!IS_ERR(bdev))
+                               bdput(bdev);
                        if (attr == &ksysfs_register_quiet)
                                goto out;
                }