From: Wei Yongjun Date: Mon, 22 Jul 2019 14:12:36 +0000 (+0800) Subject: bcache: fix possible memory leak in bch_cached_dev_run() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5d9e06d60eee95e021ffccf0d2c7ed800ae9dc14;p=linux.git 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 Signed-off-by: Coly Li Signed-off-by: Jens Axboe --- diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 26e374fbf57c7..20ed838e9413b 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; }