public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, Pavel Begunkov <[email protected]>
Subject: [PATCH 1/4] io_uring: clean up timeout async_data allocation
Date: Mon, 18 Oct 2021 00:29:33 +0000	[thread overview]
Message-ID: <16f63174013deac5076b2f63bd1301664af71f34.1634516914.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

opcode prep functions are one of the first things that are called, we
can't have ->async_data allocated at this point and it's certainly a
bug. Reflect this assumption in io_timeout_prep() and add a WARN_ONCE
just in case.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 7ead1507be9b..acda36166a9a 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -6120,7 +6120,9 @@ static int io_timeout_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,
 	if (unlikely(off && !req->ctx->off_timeout_used))
 		req->ctx->off_timeout_used = true;
 
-	if (!req_has_async_data(req) && io_alloc_async_data(req))
+	if (WARN_ON_ONCE(req_has_async_data(req)))
+		return -EFAULT;
+	if (io_alloc_async_data(req))
 		return -ENOMEM;
 
 	data = req->async_data;
-- 
2.33.1


  reply	other threads:[~2021-10-18  0:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18  0:29 [PATCH 0/4] for-next cleanups Pavel Begunkov
2021-10-18  0:29 ` Pavel Begunkov [this message]
2021-10-18  0:29 ` [PATCH 2/4] io_uring: kill unused param from io_file_supports_nowait Pavel Begunkov
2021-10-18  0:29 ` [PATCH 3/4] io_uring: clusterise ki_flags access in rw_prep Pavel Begunkov
2021-10-18  0:29 ` [PATCH 4/4] io_uring: typed ->async_data Pavel Begunkov

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=16f63174013deac5076b2f63bd1301664af71f34.1634516914.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox