public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] io_uring/rsrc: take unsigned index in io_rsrc_node_lookup()
@ 2026-01-22 21:45 Caleb Sander Mateos
  2026-01-22 22:59 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Caleb Sander Mateos @ 2026-01-22 21:45 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Caleb Sander Mateos, io-uring, linux-kernel

io_rsrc_node_lookup() takes a signed int index as input and compares it
to an unsigned length. Since the signed int is implicitly cast to an
unsigned int for the comparison and the length is bounded by
IORING_MAX_FIXED_FILES/IORING_MAX_REG_BUFFERS, negative indices are
already rejected on architectures where int is at least 32 bits. Make
this a bit clearer and avoid compiler warnings for comparisons of
signed and unsigned values by taking an unsigned int index instead.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
 io_uring/rsrc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index d603f6a47f5e..4a5db2ad1af2 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -88,11 +88,11 @@ int io_validate_user_buf_range(u64 uaddr, u64 ulen);
 
 bool io_check_coalesce_buffer(struct page **page_array, int nr_pages,
 			      struct io_imu_folio_data *data);
 
 static inline struct io_rsrc_node *io_rsrc_node_lookup(struct io_rsrc_data *data,
-						       int index)
+						       unsigned int index)
 {
 	if (index < data->nr)
 		return data->nodes[array_index_nospec(index, data->nr)];
 	return NULL;
 }
-- 
2.45.2


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

end of thread, other threads:[~2026-01-22 22:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-22 21:45 [PATCH] io_uring/rsrc: take unsigned index in io_rsrc_node_lookup() Caleb Sander Mateos
2026-01-22 22:59 ` Jens Axboe

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