Skip to content

Commit 0d7c115

Browse files
alviroiskandaraxboe
authored andcommitted
io_uring: Clean up a false-positive warning from GCC 9.3.0
In io_recv(), if import_single_range() fails, the @flags variable is uninitialized, then it will goto out_free. After the goto, the compiler doesn't know that (ret < min_ret) is always true, so it thinks the "if ((flags & MSG_WAITALL) ..." path could be taken. The complaint comes from gcc-9 (Debian 9.3.0-22) 9.3.0: ``` fs/io_uring.c:5238 io_recvfrom() error: uninitialized symbol 'flags' ``` Fix this by bypassing the @ret and @flags check when import_single_range() fails. Reasons: 1. import_single_range() only returns -EFAULT when it fails. 2. At that point, @flags is uninitialized and shouldn't be read. Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Reported-by: "Chen, Rong A" <[email protected]> Link: https://lore.gnuweeb.org/timl/[email protected]/ Cc: Pavel Begunkov <[email protected]> Suggested-by: Ammar Faizi <[email protected]> Fixes: 7297ce3 ("io_uring: improve send/recv error handling") Signed-off-by: Alviro Iskandar Setiawan <[email protected]> Signed-off-by: Ammar Faizi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent f6133fb commit 0d7c115

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

fs/io_uring.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5228,17 +5228,16 @@ static int io_recv(struct io_kiocb *req, unsigned int issue_flags)
52285228
min_ret = iov_iter_count(&msg.msg_iter);
52295229

52305230
ret = sock_recvmsg(sock, &msg, flags);
5231-
out_free:
52325231
if (ret < min_ret) {
52335232
if (ret == -EAGAIN && force_nonblock)
52345233
return -EAGAIN;
52355234
if (ret == -ERESTARTSYS)
52365235
ret = -EINTR;
52375236
req_set_fail(req);
52385237
} else if ((flags & MSG_WAITALL) && (msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))) {
5238+
out_free:
52395239
req_set_fail(req);
52405240
}
5241-
52425241
__io_req_complete(req, issue_flags, ret, io_put_kbuf(req));
52435242
return 0;
52445243
}

0 commit comments

Comments
 (0)