blob: 7f1480af654a4289ea2ce199b8fe8168cb603548 [file] [log] [blame]
From 0a019fcd6f4f442a56bf5f2c87268bb3ba9ed396 Mon Sep 17 00:00:00 2001
From: Coly Li <>
Date: Fri, 24 Jan 2020 01:01:29 +0800
Subject: [PATCH] bcache: properly initialize 'path' and 'err' in
commit 29cda393bcaad160c4bf3676ddd99855adafc72f upstream.
Patch "bcache: rework error unwinding in register_bcache" from
Christoph Hellwig changes the local variables 'path' and 'err'
in undefined initial state. If the code in register_bcache() jumps
to label 'out:' or 'out_module_put:' by goto, these two variables
might be reference with undefined value by the following line,
pr_info("error %s: %s", path, err);
return ret;
Therefore this patch initializes these two local variables properly
in register_bcache() to avoid such issue.
Signed-off-by: Coly Li <>
Signed-off-by: Jens Axboe <>
Signed-off-by: Paul Gortmaker <>
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 25fa9f85599d..013c7772f232 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2301,18 +2301,20 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
const char *buffer, size_t size)
const char *err;
- char *path;
+ char *path = NULL;
struct cache_sb *sb;
struct block_device *bdev = NULL;
struct page *sb_page;
ssize_t ret;
ret = -EBUSY;
+ err = "failed to reference bcache module";
if (!try_module_get(THIS_MODULE))
goto out;
/* For latest state of bcache_is_reboot */
+ err = "bcache is in reboot";
if (bcache_is_reboot)
goto out_module_put;