io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bixuan Cui <cuibixuan@huawei.com>
To: <linux-kernel@vger.kernel.org>, <io-uring@vger.kernel.org>
Cc: <axboe@kernel.dk>, <asml.silence@gmail.com>, <john.wanghui@huawei.com>
Subject: [PATCH -next] io-wq: Fix memory leak in create_io_worker
Date: Thu, 9 Sep 2021 16:49:19 +0800	[thread overview]
Message-ID: <20210909084919.29644-1-cuibixuan@huawei.com> (raw)

If io_should_retry_thread is false, free the worker before goto fails.

Fixes: 3146cba99aa2 ("io-wq: make worker creation resilient against signals")
Reported-by: syzbot+65454c239241d3d647da@syzkaller.appspotmail.com
Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
---
 fs/io-wq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/io-wq.c b/fs/io-wq.c
index d80e4a735677..036953f334d4 100644
--- a/fs/io-wq.c
+++ b/fs/io-wq.c
@@ -759,6 +759,7 @@ static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index)
 	if (!IS_ERR(tsk)) {
 		io_init_new_worker(wqe, worker, tsk);
 	} else if (!io_should_retry_thread(PTR_ERR(tsk))) {
+		kfree(worker);
 		goto fail;
 	} else {
 		INIT_WORK(&worker->work, io_workqueue_create);
-- 
2.17.1


             reply	other threads:[~2021-09-09  8:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  8:49 Bixuan Cui [this message]
2021-09-09 12:58 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210909084919.29644-1-cuibixuan@huawei.com \
    --to=cuibixuan@huawei.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=john.wanghui@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH -next] io-wq: Fix memory leak in create_io_worker' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).