summaryrefslogtreecommitdiff
path: root/drivers/md/bcache/super.c
diff options
context:
space:
mode:
authorWei Yongjun <weiyongjun1@huawei.com>2019-07-22 17:12:36 +0300
committerJens Axboe <axboe@kernel.dk>2019-07-22 17:15:17 +0300
commit5d9e06d60eee95e021ffccf0d2c7ed800ae9dc14 (patch)
tree97cdecef1fbeaa5205e732ee8695f00d80806beb /drivers/md/bcache/super.c
parent9310a7ba6de8cce6209e3e8a3cdf733f824cdd9b (diff)
downloadlinux-5d9e06d60eee95e021ffccf0d2c7ed800ae9dc14.tar.xz
bcache: fix possible memory leak in bch_cached_dev_run()
memory malloced in bch_cached_dev_run() and should be freed before leaving from the error handling cases, otherwise it will cause memory leak. Fixes: 0b13efecf5f2 ("bcache: add return value check to bch_cached_dev_run()") Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Coly Li <colyli@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md/bcache/super.c')
-rw-r--r--drivers/md/bcache/super.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 26e374fbf57c..20ed838e9413 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -931,6 +931,9 @@ int bch_cached_dev_run(struct cached_dev *dc)
if (dc->io_disable) {
pr_err("I/O disabled on cached dev %s",
dc->backing_dev_name);
+ kfree(env[1]);
+ kfree(env[2]);
+ kfree(buf);
return -EIO;
}