Skip to content

Commit 86c77f6

Browse files
committed
Merge branch 'for-6.11/io_uring' into for-next
* for-6.11/io_uring: io_uring/msg_ring: use kmem_cache_free() to free request io_uring/msg_ring: check for dead submitter task
2 parents ce62bd2 + be4f5d9 commit 86c77f6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

io_uring/msg_ring.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,25 @@ static void io_msg_tw_complete(struct io_kiocb *req, struct io_tw_state *ts)
8282
spin_unlock(&ctx->msg_lock);
8383
}
8484
if (req)
85-
kfree(req);
85+
kmem_cache_free(req_cachep, req);
8686
percpu_ref_put(&ctx->refs);
8787
}
8888

89-
static void io_msg_remote_post(struct io_ring_ctx *ctx, struct io_kiocb *req,
90-
int res, u32 cflags, u64 user_data)
89+
static int io_msg_remote_post(struct io_ring_ctx *ctx, struct io_kiocb *req,
90+
int res, u32 cflags, u64 user_data)
9191
{
92+
req->task = READ_ONCE(ctx->submitter_task);
93+
if (!req->task) {
94+
kmem_cache_free(req_cachep, req);
95+
return -EOWNERDEAD;
96+
}
9297
req->cqe.user_data = user_data;
9398
io_req_set_res(req, res, cflags);
9499
percpu_ref_get(&ctx->refs);
95100
req->ctx = ctx;
96-
req->task = READ_ONCE(ctx->submitter_task);
97101
req->io_task_work.func = io_msg_tw_complete;
98102
io_req_task_work_add_remote(req, ctx, IOU_F_TWQ_LAZY_WAKE);
103+
return 0;
99104
}
100105

101106
static struct io_kiocb *io_msg_get_kiocb(struct io_ring_ctx *ctx)
@@ -125,8 +130,8 @@ static int io_msg_data_remote(struct io_kiocb *req)
125130
if (msg->flags & IORING_MSG_RING_FLAGS_PASS)
126131
flags = msg->cqe_flags;
127132

128-
io_msg_remote_post(target_ctx, target, msg->len, flags, msg->user_data);
129-
return 0;
133+
return io_msg_remote_post(target_ctx, target, msg->len, flags,
134+
msg->user_data);
130135
}
131136

132137
static int io_msg_ring_data(struct io_kiocb *req, unsigned int issue_flags)

0 commit comments

Comments
 (0)