Commit b7837a71 authored by Jan Kara's avatar Jan Kara Committed by Li Lingfeng
Browse files

bcache: Fixup error handling in register_cache()

mainline inclusion
from mainline-v6.7-rc1
commit b3856da7906257a80a764d3dfc6b25e876a4403c
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8KPBR
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.7-rc3&id=b3856da7906257a80a764d3dfc6b25e876a4403c



-------------------------------------------

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: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20231004093757.11560-1-jack@suse.cz


Asked-by: default avatarColy Li <colyli@suse.de>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
Signed-off-by: default avatarLi Lingfeng <lilingfeng3@huawei.com>
parent 4cea6782
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment