Skip to content

Commit 093457f

Browse files
jankaragregkh
authored andcommitted
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>
1 parent 5025da3 commit 093457f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/md/bcache/super.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,6 +1960,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
19601960
else
19611961
err = "device busy";
19621962
mutex_unlock(&bch_register_lock);
1963+
if (!IS_ERR(bdev))
1964+
bdput(bdev);
19631965
if (attr == &ksysfs_register_quiet)
19641966
goto out;
19651967
}

0 commit comments

Comments
 (0)