io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] io_uring: add cleanup for openat()
@ 2020-02-07 20:45 Pavel Begunkov
  2020-02-07 20:53 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Begunkov @ 2020-02-07 20:45 UTC (permalink / raw)
  To: Jens Axboe, io-uring, linux-kernel

openat() have allocated ->open.filename, which need to be put.
Add cleanup handlers for it.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 fs/io_uring.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index b0e6b3bc1aec..42b7861b534c 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2547,6 +2547,7 @@ static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 		return ret;
 	}
 
+	req->flags |= REQ_F_NEED_CLEANUP;
 	return 0;
 }
 
@@ -2585,6 +2586,7 @@ static int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 		return ret;
 	}
 
+	req->flags |= REQ_F_NEED_CLEANUP;
 	return 0;
 }
 
@@ -2616,6 +2618,7 @@ static int io_openat2(struct io_kiocb *req, struct io_kiocb **nxt,
 	}
 err:
 	putname(req->open.filename);
+	req->flags &= ~REQ_F_NEED_CLEANUP;
 	if (ret < 0)
 		req_set_fail_links(req);
 	io_cqring_add_event(req, ret);
@@ -2857,7 +2860,6 @@ static void io_close_finish(struct io_wq_work **workptr)
 	}
 
 	fput(req->close.put_file);
-
 	io_put_req_find_next(req, &nxt);
 	if (nxt)
 		io_wq_assign_next(workptr, nxt);
@@ -4233,6 +4235,10 @@ static void io_cleanup_req(struct io_kiocb *req)
 		if (io->msg.iov != io->msg.fast_iov)
 			kfree(io->msg.iov);
 		break;
+	case IORING_OP_OPENAT:
+	case IORING_OP_OPENAT2:
+		putname(req->open.filename);
+		break;
 	}
 
 	req->flags &= ~REQ_F_NEED_CLEANUP;
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] io_uring: add cleanup for openat()
  2020-02-07 20:45 [PATCH] io_uring: add cleanup for openat() Pavel Begunkov
@ 2020-02-07 20:53 ` Jens Axboe
  2020-02-07 20:55   ` Pavel Begunkov
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2020-02-07 20:53 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring, linux-kernel

On 2/7/20 1:45 PM, Pavel Begunkov wrote:
> openat() have allocated ->open.filename, which need to be put.
> Add cleanup handlers for it.

Should this include statx too?

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] io_uring: add cleanup for openat()
  2020-02-07 20:53 ` Jens Axboe
@ 2020-02-07 20:55   ` Pavel Begunkov
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Begunkov @ 2020-02-07 20:55 UTC (permalink / raw)
  To: Jens Axboe, io-uring, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 316 bytes --]

On 07/02/2020 23:53, Jens Axboe wrote:
> On 2/7/20 1:45 PM, Pavel Begunkov wrote:
>> openat() have allocated ->open.filename, which need to be put.
>> Add cleanup handlers for it.
> 
> Should this include statx too?

It should. Missed, that statx uses the same struct.
I'll resend.

-- 
Pavel Begunkov


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-07 20:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-07 20:45 [PATCH] io_uring: add cleanup for openat() Pavel Begunkov
2020-02-07 20:53 ` Jens Axboe
2020-02-07 20:55   ` Pavel Begunkov

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).