Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Wei Yongjun and committed by
Jens Axboe
5d9e06d6 9310a7ba

+3
+3
drivers/md/bcache/super.c
··· 931 931 if (dc->io_disable) { 932 932 pr_err("I/O disabled on cached dev %s", 933 933 dc->backing_dev_name); 934 + kfree(env[1]); 935 + kfree(env[2]); 936 + kfree(buf); 934 937 return -EIO; 935 938 } 936 939