]> git.itanic.dy.fi Git - linux-stable/commit
bcache: Fixup error handling in register_cache()
authorJan Kara <jack@suse.cz>
Wed, 4 Oct 2023 09:37:57 +0000 (11:37 +0200)
committerChristian Brauner <brauner@kernel.org>
Sat, 28 Oct 2023 11:29:22 +0000 (13:29 +0200)
commitb3856da7906257a80a764d3dfc6b25e876a4403c
tree2203747a24ef4ad44af4f0d88dee972908c40882
parente340dd63f6a11402424b3d77e51149bce8fcba7d
bcache: Fixup error handling in register_cache()

Coverity has noticed that the printing of error message in
register_cache() uses already freed bdev_handle to get to bdev. In fact
the problem has been there even before commit "bcache: Convert to
bdev_open_by_path()" just a bit more subtle one - cache object itself
could have been freed by the time we looked at ca->bdev and we don't
hold any reference to bdev either so even that could in principle go
away (due to device unplug or similar). Fix all these problems by
printing the error message before closing the bdev.

Fixes: dc893f51d24a ("bcache: Convert to bdev_open_by_path()")
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20231004093757.11560-1-jack@suse.cz
Asked-by: Coly Li <colyli@suse.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>
drivers/md/bcache/super.c