public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: ensure fput() called correspondingly when direct install fails
@ 2022-05-27  2:54 Xiaoguang Wang
  2022-05-27  3:52 ` Jens Axboe
  2022-05-28  2:14 ` Jens Axboe
  0 siblings, 2 replies; 4+ messages in thread
From: Xiaoguang Wang @ 2022-05-27  2:54 UTC (permalink / raw)
  To: io-uring; +Cc: axboe, asml.silence

io_fixed_fd_install() may fail for short of free fixed file bitmap,
in this case, need to call fput() correspondingly.

Signed-off-by: Xiaoguang Wang <[email protected]>
---
 fs/io_uring.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index d50bbf8de4fb..0190947fb1bf 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5438,6 +5438,10 @@ static int io_file_bitmap_get(struct io_ring_ctx *ctx)
 	return -ENFILE;
 }
 
+/*
+ * Note when io_fixed_fd_install() returns error value, it will ensure
+ * fput() is called correspondingly.
+ */
 static int io_fixed_fd_install(struct io_kiocb *req, unsigned int issue_flags,
 			       struct file *file, unsigned int file_slot)
 {
@@ -5450,6 +5454,7 @@ static int io_fixed_fd_install(struct io_kiocb *req, unsigned int issue_flags,
 		ret = io_file_bitmap_get(ctx);
 		if (unlikely(ret < 0)) {
 			io_ring_submit_unlock(ctx, issue_flags);
+			fput(file);
 			return ret;
 		}
 
-- 
2.14.4.44.g2045bb6


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

* Re: [PATCH] io_uring: ensure fput() called correspondingly when direct install fails
  2022-05-27  2:54 [PATCH] io_uring: ensure fput() called correspondingly when direct install fails Xiaoguang Wang
@ 2022-05-27  3:52 ` Jens Axboe
  2022-05-27  4:08   ` Xiaoguang Wang
  2022-05-28  2:14 ` Jens Axboe
  1 sibling, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2022-05-27  3:52 UTC (permalink / raw)
  To: Xiaoguang Wang, io-uring; +Cc: asml.silence

On 5/26/22 8:54 PM, Xiaoguang Wang wrote:
> io_fixed_fd_install() may fail for short of free fixed file bitmap,
> in this case, need to call fput() correspondingly.

Good catch - but it's a bit confusing how we handle this case
internally, and the other error case relies on that function doing the
fput (which it does).

Any chance we can get that cleaned up at the same time? Would make
errors in this error less likely in the future.

-- 
Jens Axboe


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

* Re: [PATCH] io_uring: ensure fput() called correspondingly when direct install fails
  2022-05-27  3:52 ` Jens Axboe
@ 2022-05-27  4:08   ` Xiaoguang Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Xiaoguang Wang @ 2022-05-27  4:08 UTC (permalink / raw)
  To: Jens Axboe, io-uring; +Cc: asml.silence

hi,

> On 5/26/22 8:54 PM, Xiaoguang Wang wrote:
>> io_fixed_fd_install() may fail for short of free fixed file bitmap,
>> in this case, need to call fput() correspondingly.
> Good catch - but it's a bit confusing how we handle this case
> internally, and the other error case relies on that function doing the
> fput (which it does).
>
> Any chance we can get that cleaned up at the same time? Would make
> errors in this error less likely in the future.
OK, sure, will try to prepare a better one.

Regards,
Xiaoguang Wang
>


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

* Re: [PATCH] io_uring: ensure fput() called correspondingly when direct install fails
  2022-05-27  2:54 [PATCH] io_uring: ensure fput() called correspondingly when direct install fails Xiaoguang Wang
  2022-05-27  3:52 ` Jens Axboe
@ 2022-05-28  2:14 ` Jens Axboe
  1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2022-05-28  2:14 UTC (permalink / raw)
  To: io-uring, xiaoguang.wang; +Cc: asml.silence

On Fri, 27 May 2022 10:54:00 +0800, Xiaoguang Wang wrote:
> io_fixed_fd_install() may fail for short of free fixed file bitmap,
> in this case, need to call fput() correspondingly.
> 
> 

Applied, thanks!

[1/1] io_uring: ensure fput() called correspondingly when direct install fails
      commit: 1c145c7f3616ec48725edeac8edf26ee6ed4b661

Best regards,
-- 
Jens Axboe



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

end of thread, other threads:[~2022-05-28  2:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-27  2:54 [PATCH] io_uring: ensure fput() called correspondingly when direct install fails Xiaoguang Wang
2022-05-27  3:52 ` Jens Axboe
2022-05-27  4:08   ` Xiaoguang Wang
2022-05-28  2:14 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox