Skip to contentSkip to conversation

io_uring: fix shadowed variable ret return code being not checked

PATCH Applied Colin King 2 participants 2 messages May 5, 2019 – May 6, 2019

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 io_uring: fix shadowed variable ret return code being not checked

From: Colin Ian King <[email protected]>

Currently variable ret is declared in a while-loop code block that shadows another variable ret. When an error occurs in the while-loop the error return in ret is not being set in the outer code block and so the error check on ret is always going to be checking on the wrong ret variable resulting in check that is always going to be true and a premature return occurs.

Fix this by removing the declaration of the inner while-loop variable ret so that shadowing does not occur.

Addresses-Coverity: ("'Constant' variable guards dead code")

Fixes 6b06314c47e1 ("io_uring: add file set registration")
---
 fs/io_uring.c | 1 -
 1 file changed, 1 deletion(-)
fs/io_uring.c +0 -1
index 452e35357865..50f965060ef1 100644
@@ -2363,7 +2363,6 @@ static int io_sqe_files_scm(struct io_ring_ctx *ctx)
 	left = ctx->nr_user_files;
 	while (left) {
 		unsigned this_files = min_t(unsigned, left, SCM_MAX_FD);
-		int ret;
 
 		ret = __io_sqe_files_scm(ctx, this_files, total);
 		if (ret)
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw
Quoted 11 lines · Colin King

From: Colin Ian King <[email protected]>

Currently variable ret is declared in a while-loop code block that shadows another variable ret. When an error occurs in the while-loop the error return in ret is not being set in the outer code block and so the error check on ret is always going to be checking on the wrong ret variable resulting in check that is always going to be true and a premature return occurs.

Fix this by removing the declaration of the inner while-loop variable ret so that shadowing does not occur.

Thanks, applied.

Signature · 1 line
Jens Axboe