Skip to content

Commit 1f5e98e

Browse files
committed
Merge tag 'io_uring-5.18-2022-04-22' of git://git.kernel.dk/linux-block
Pull io_uring fixes from Jens Axboe: "Just two small fixes - one fixing a potential leak for the iovec for larger requests added in this cycle, and one fixing a theoretical leak with CQE_SKIP and IOPOLL" * tag 'io_uring-5.18-2022-04-22' of git://git.kernel.dk/linux-block: io_uring: fix leaks on IOPOLL and CQE_SKIP io_uring: free iovec if file assignment fails
2 parents 45ab940 + c071354 commit 1f5e98e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fs/io_uring.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2797,11 +2797,10 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, bool force_nonspin)
27972797
/* order with io_complete_rw_iopoll(), e.g. ->result updates */
27982798
if (!smp_load_acquire(&req->iopoll_completed))
27992799
break;
2800+
nr_events++;
28002801
if (unlikely(req->flags & REQ_F_CQE_SKIP))
28012802
continue;
2802-
28032803
__io_fill_cqe_req(req, req->result, io_put_kbuf(req, 0));
2804-
nr_events++;
28052804
}
28062805

28072806
if (unlikely(!nr_events))
@@ -3832,8 +3831,10 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags)
38323831
iovec = NULL;
38333832
}
38343833
ret = io_rw_init_file(req, FMODE_READ);
3835-
if (unlikely(ret))
3834+
if (unlikely(ret)) {
3835+
kfree(iovec);
38363836
return ret;
3837+
}
38373838
req->result = iov_iter_count(&s->iter);
38383839

38393840
if (force_nonblock) {
@@ -3958,8 +3959,10 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags)
39583959
iovec = NULL;
39593960
}
39603961
ret = io_rw_init_file(req, FMODE_WRITE);
3961-
if (unlikely(ret))
3962+
if (unlikely(ret)) {
3963+
kfree(iovec);
39623964
return ret;
3965+
}
39633966
req->result = iov_iter_count(&s->iter);
39643967

39653968
if (force_nonblock) {

0 commit comments

Comments
 (0)