Btrfs: async-thread: fix possible memory leak
When kthread_run() returns failure, this worker hasn't been
added to the list, so btrfs_stop_workers() won't free it.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 8d4cc46..5fe6a0d 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -187,6 +187,7 @@
worker->task = kthread_run(worker_loop, worker, "btrfs");
worker->workers = workers;
if (IS_ERR(worker->task)) {
+ kfree(worker);
ret = PTR_ERR(worker->task);
goto fail;
}