* [PATCH] io_uring: Fix incorrect variable type in io_fixed_fd_install
@ 2022-05-12 12:05 Wan Jiabing
2022-05-12 12:21 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Wan Jiabing @ 2022-05-12 12:05 UTC (permalink / raw)
To: Jens Axboe, Pavel Begunkov, io-uring, linux-kernel; +Cc: Wan Jiabing
Fix following coccicheck warning:
fs/io_uring.c:5352:15-24: WARNING: Unsigned expression compared with zero: file_slot < 0
'file_slot' is an unsigned variable and it can't be less than 0.
Use 'ret' instead to check the error code from io_file_bitmap_get().
And using bool to declare 'alloc_slot' makes the code better.
Fixes: 08cf52bc6eb4 ("io_uring: allow allocated fixed files for openat/openat2")
Signed-off-by: Wan Jiabing <[email protected]>
---
fs/io_uring.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index e8f5106434ad..92d0321bdefe 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5342,17 +5342,19 @@ static int io_file_bitmap_get(struct io_ring_ctx *ctx)
static int io_fixed_fd_install(struct io_kiocb *req, unsigned int issue_flags,
struct file *file, unsigned int file_slot)
{
- int alloc_slot = file_slot == IORING_FILE_INDEX_ALLOC;
+ bool alloc_slot = file_slot == IORING_FILE_INDEX_ALLOC;
struct io_ring_ctx *ctx = req->ctx;
int ret;
if (alloc_slot) {
io_ring_submit_lock(ctx, issue_flags);
- file_slot = io_file_bitmap_get(ctx);
- if (unlikely(file_slot < 0)) {
+ ret = io_file_bitmap_get(ctx);
+ if (unlikely(ret < 0)) {
io_ring_submit_unlock(ctx, issue_flags);
- return file_slot;
+ return ret;
}
+
+ file_slot = ret;
}
ret = io_install_fixed_file(req, file, issue_flags, file_slot);
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-12 12:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-12 12:05 [PATCH] io_uring: Fix incorrect variable type in io_fixed_fd_install Wan Jiabing
2022-05-12 12:21 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox