Skip to content

Commit 323b190

Browse files
committed
io_uring: free iovec if file assignment fails
We just return failure in this case, but we need to release the iovec first. If we're doing IO with more than FAST_IOV segments, then the iovec is allocated and must be freed. Reported-by: syzbot+96b43810dfe9c3bb95ed@syzkaller.appspotmail.com Fixes: 584b018 ("io_uring: move read/write file prep state into actual opcode handler") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 7015214 commit 323b190

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/io_uring.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3832,8 +3832,10 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags)
38323832
iovec = NULL;
38333833
}
38343834
ret = io_rw_init_file(req, FMODE_READ);
3835-
if (unlikely(ret))
3835+
if (unlikely(ret)) {
3836+
kfree(iovec);
38363837
return ret;
3838+
}
38373839
req->result = iov_iter_count(&s->iter);
38383840

38393841
if (force_nonblock) {
@@ -3958,8 +3960,10 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags)
39583960
iovec = NULL;
39593961
}
39603962
ret = io_rw_init_file(req, FMODE_WRITE);
3961-
if (unlikely(ret))
3963+
if (unlikely(ret)) {
3964+
kfree(iovec);
39623965
return ret;
3966+
}
39633967
req->result = iov_iter_count(&s->iter);
39643968

39653969
if (force_nonblock) {

0 commit comments

Comments
 (0)