@@ -82,20 +82,25 @@ static void io_msg_tw_complete(struct io_kiocb *req, struct io_tw_state *ts)
82
82
spin_unlock (& ctx -> msg_lock );
83
83
}
84
84
if (req )
85
- kfree ( req );
85
+ kmem_cache_free ( req_cachep , req );
86
86
percpu_ref_put (& ctx -> refs );
87
87
}
88
88
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 )
91
91
{
92
+ req -> task = READ_ONCE (ctx -> submitter_task );
93
+ if (!req -> task ) {
94
+ kmem_cache_free (req_cachep , req );
95
+ return - EOWNERDEAD ;
96
+ }
92
97
req -> cqe .user_data = user_data ;
93
98
io_req_set_res (req , res , cflags );
94
99
percpu_ref_get (& ctx -> refs );
95
100
req -> ctx = ctx ;
96
- req -> task = READ_ONCE (ctx -> submitter_task );
97
101
req -> io_task_work .func = io_msg_tw_complete ;
98
102
io_req_task_work_add_remote (req , ctx , IOU_F_TWQ_LAZY_WAKE );
103
+ return 0 ;
99
104
}
100
105
101
106
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)
125
130
if (msg -> flags & IORING_MSG_RING_FLAGS_PASS )
126
131
flags = msg -> cqe_flags ;
127
132
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 ) ;
130
135
}
131
136
132
137
static int io_msg_ring_data (struct io_kiocb * req , unsigned int issue_flags )
0 commit comments