Skip to content

Commit 496f56b

Browse files
calebsanderaxboe
authored andcommitted
io_uring/rsrc: avoid NULL check in io_put_rsrc_node()
Most callers of io_put_rsrc_node() already check that node is non-NULL: - io_rsrc_data_free() - io_sqe_buffer_register() - io_reset_rsrc_node() - io_req_put_rsrc_nodes() (REQ_F_BUF_NODE indicates non-NULL buf_node) Only io_splice_cleanup() can call io_put_rsrc_node() with a NULL node. So move the NULL check there. Signed-off-by: Caleb Sander Mateos <csander@purestorage.com> Link: https://lore.kernel.org/r/20250216225900.1075446-1-csander@purestorage.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 60e6ce7 commit 496f56b

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

io_uring/rsrc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static inline struct io_rsrc_node *io_rsrc_node_lookup(struct io_rsrc_data *data
8383
static inline void io_put_rsrc_node(struct io_ring_ctx *ctx, struct io_rsrc_node *node)
8484
{
8585
lockdep_assert_held(&ctx->uring_lock);
86-
if (node && !--node->refs)
86+
if (!--node->refs)
8787
io_free_rsrc_node(ctx, node);
8888
}
8989

io_uring/splice.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ void io_splice_cleanup(struct io_kiocb *req)
5151
{
5252
struct io_splice *sp = io_kiocb_to_cmd(req, struct io_splice);
5353

54-
io_put_rsrc_node(req->ctx, sp->rsrc_node);
54+
if (sp->rsrc_node)
55+
io_put_rsrc_node(req->ctx, sp->rsrc_node);
5556
}
5657

5758
static struct file *io_splice_get_file(struct io_kiocb *req,

0 commit comments

Comments
 (0)