diff mbox series

[1/1] bcache: fix possible memory leak in bch_cached_dev_run()

Message ID 20190722141236.103967-2-colyli@suse.de (mailing list archive)
State New, archived
Headers show
Series bcache fix for Linux v5.3-rc2 | expand

Commit Message

Coly Li July 22, 2019, 2:12 p.m. UTC
From: Wei Yongjun <weiyongjun1@huawei.com>

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>
---
 drivers/md/bcache/super.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jens Axboe July 22, 2019, 2:15 p.m. UTC | #1
On 7/22/19 8:12 AM, Coly Li wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> memory malloced in bch_cached_dev_run() and should be freed before
> leaving from the error handling cases, otherwise it will cause
> memory leak.

Applied, thanks.
diff mbox series

Patch

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;
 	}