[lkml]   [2019]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 4.19 188/271] bcache: destroy dc->writeback_write_wq if failed to create dc->writeback_thread
From: Coly Li <>

commit f54d801dda14942dbefa00541d10603015b7859c upstream.

Commit 9baf30972b55 ("bcache: fix for gc and write-back race") added a
new work queue dc->writeback_write_wq, but forgot to destroy it in the
error condition when creating dc->writeback_thread failed.

This patch destroys dc->writeback_write_wq if kthread_create() returns
error pointer to dc->writeback_thread, then a memory leak is avoided.

Fixes: 9baf30972b55 ("bcache: fix for gc and write-back race")
Signed-off-by: Coly Li <>
Signed-off-by: Jens Axboe <>
Signed-off-by: Greg Kroah-Hartman <>

drivers/md/bcache/writeback.c | 1 +
1 file changed, 1 insertion(+)

--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -807,6 +807,7 @@ int bch_cached_dev_writeback_start(struc
if (IS_ERR(dc->writeback_thread)) {
+ destroy_workqueue(dc->writeback_write_wq);
return PTR_ERR(dc->writeback_thread);

 \ /
  Last update: 2019-07-25 07:44    [W:0.687 / U:1.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site