diff options
author | Coly Li <colyli@suse.de> | 2018-05-16 22:21:51 +0800 |
---|---|---|
committer | Coly Li <colyli@suse.de> | 2018-05-16 22:21:51 +0800 |
commit | 13790bffba9b476d2a1066a41389f73ab53b8ba5 (patch) | |
tree | 6a7aa5adfccfe44e6ad755b1b5441b6c49e8822b | |
parent | 7fc3c9f120ea71481fcbb5af56e44a422496a756 (diff) | |
download | bcache-patches-13790bffba9b476d2a1066a41389f73ab53b8ba5.tar.gz |
update for-test and for-current
-rw-r--r-- | for-current/0001-bcache-return-0-from-bch_debug_init-if-CONFIG_DEBUG_.patch | 65 | ||||
-rw-r--r-- | for-test/0001-bcache-initiate-bcache_debug-to-NULL.patch | 39 |
2 files changed, 104 insertions, 0 deletions
diff --git a/for-current/0001-bcache-return-0-from-bch_debug_init-if-CONFIG_DEBUG_.patch b/for-current/0001-bcache-return-0-from-bch_debug_init-if-CONFIG_DEBUG_.patch new file mode 100644 index 0000000..6a5c71a --- /dev/null +++ b/for-current/0001-bcache-return-0-from-bch_debug_init-if-CONFIG_DEBUG_.patch @@ -0,0 +1,65 @@ +From 0bc88c2b4669e476b9e5fdf2fa29b0c27d5a761f Mon Sep 17 00:00:00 2001 +From: Coly Li <colyli@suse.de> +Date: Wed, 16 May 2018 20:22:47 +0800 +Subject: [PATCH] bcache: return 0 from bch_debug_init() if CONFIG_DEBUG_FS=n + +Commit 539d39eb2708 ("bcache: fix wrong return value in bch_debug_init()") +returns the return value of debugfs_create_dir() to bcache_init(). When +CONFIG_DEBUG_FS=n, bch_debug_init() always returns 1 and makes +bcache_init() failedi. + +This patch makes bch_debug_init() always returns 0 if CONFIG_DEBUG_FS=n, +so bcache can continue to work for the kernels which don't have debugfs +enanbled. + +Fixes: Commit 539d39eb2708 ("bcache: fix wrong return value in bch_debug_init()") +Cc: stable@vger.kernel.org +Signed-off-by: Coly Li <colyli@suse.de> +Reported-by: Massimo B. <massimo.b@gmx.net> +Reported-by: Kai Krakow <kai@kaishome.de> +Cc: Kent Overstreet <kent.overstreet@gmail.com> +--- + drivers/md/bcache/bcache.h | 5 +++++ + drivers/md/bcache/debug.c | 4 ++-- + 2 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h +index 3a0cfb237af9..5b3fe87f32ee 100644 +--- a/drivers/md/bcache/bcache.h ++++ b/drivers/md/bcache/bcache.h +@@ -994,8 +994,13 @@ void bch_open_buckets_free(struct cache_set *); + + int bch_cache_allocator_start(struct cache *ca); + ++#ifdef CONFIG_DEBUG_FS + void bch_debug_exit(void); + int bch_debug_init(struct kobject *); ++#else ++static inline void bch_debug_exit(void) {}; ++static inline int bch_debug_init(struct kobject *kobj) { return 0; }; ++#endif + void bch_request_exit(void); + int bch_request_init(void); + +diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c +index 4e63c6f6c04d..34a0ed4ed70c 100644 +--- a/drivers/md/bcache/debug.c ++++ b/drivers/md/bcache/debug.c +@@ -240,8 +240,6 @@ void bch_debug_init_cache_set(struct cache_set *c) + } + } + +-#endif +- + void bch_debug_exit(void) + { + if (!IS_ERR_OR_NULL(bcache_debug)) +@@ -254,3 +252,5 @@ int __init bch_debug_init(struct kobject *kobj) + + return IS_ERR_OR_NULL(bcache_debug); + } ++ ++#endif +-- +2.16.3 + diff --git a/for-test/0001-bcache-initiate-bcache_debug-to-NULL.patch b/for-test/0001-bcache-initiate-bcache_debug-to-NULL.patch new file mode 100644 index 0000000..56b174f --- /dev/null +++ b/for-test/0001-bcache-initiate-bcache_debug-to-NULL.patch @@ -0,0 +1,39 @@ +From 54ba2a8cc13f823c4bfe34eacf3ffa045dcdb82a Mon Sep 17 00:00:00 2001 +From: Coly Li <colyli@suse.de> +Date: Wed, 16 May 2018 22:10:53 +0800 +Subject: [PATCH] bcache: initiate bcache_debug to NULL + +Global variable bcache_debug is firstly initialized in bch_debug_init(), +and destroyed in bch_debug_exit(). bch_debug_init() is called in +bcache_init() with many other functions, if one of the previous calling +onces failed, bcache_exit() will be called in the failure path. + +The problem is, if bcache_init() fails before bch_debug_init() is called, +then in bcache_exit() when bch_debug_exit() is called to destroy global +variable bcache_debug, at this moment bcache_debug is unndefined, then the +test of "if (!IS_ERR_OR_NULL(bcache_debug))" might be buggy. + +This patch initializes global varabile bcache_debug to be NULL, to make +the failure code path to be predictable. + +Signed-off-by: Coly Li <colyli@suse.de> +--- + drivers/md/bcache/debug.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c +index 34a0ed4ed70c..f1c3545ab6a4 100644 +--- a/drivers/md/bcache/debug.c ++++ b/drivers/md/bcache/debug.c +@@ -17,7 +17,7 @@ + #include <linux/random.h> + #include <linux/seq_file.h> + +-struct dentry *bcache_debug; ++struct dentry *bcache_debug = NULL; + + #ifdef CONFIG_BCACHE_DEBUG + +-- +2.16.3 + |