Skip to content

Commit f261c16

Browse files
isilenceaxboe
authored andcommitted
io_uring: comment on kfree(iovec) checks
kfree() handles NULL pointers well, but io_{read,write}() checks it because of performance reasons. Leave a comment there for those who are tempted to patch it. Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent bb17534 commit f261c16

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/io_uring.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3204,6 +3204,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
32043204
kiocb_done(kiocb, ret, cs);
32053205
ret = 0;
32063206
out_free:
3207+
/* it's reportedly faster than delegating the null check to kfree() */
32073208
if (iovec)
32083209
kfree(iovec);
32093210
return ret;
@@ -3300,6 +3301,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,
33003301
return -EAGAIN;
33013302
}
33023303
out_free:
3304+
/* it's reportedly faster than delegating the null check to kfree() */
33033305
if (iovec)
33043306
kfree(iovec);
33053307
return ret;

0 commit comments

Comments
 (0)