diff options
author | Jan Kara <jack@suse.cz> | 2017-09-06 09:25:51 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-09-27 11:57:21 +0300 |
commit | 615f8ab2ffcdd13ad0ce98e62a5268f9954893a6 (patch) | |
tree | 6855b31a620dc308e75d68afc3a9230b71bf5981 | |
parent | cfa0386af092a3afcf5edc8930ed7bb4990697e3 (diff) | |
download | linux-615f8ab2ffcdd13ad0ce98e62a5268f9954893a6.tar.xz |
bcache: Fix leak of bdev reference
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>
-rw-r--r-- | drivers/md/bcache/super.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 2b4fae01381f..38522cc6b26d 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1997,6 +1997,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; } |