Skip to content

Commit 51fff55

Browse files
committed
io_uring/register: have io_parse_restrictions() return number of ops
Rather than return 0 on success, return >= 0 for success, where the return value is that number of parsed entries. As before, any < 0 return is an error. Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 130a827 commit 51fff55

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

io_uring/register.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ static int io_register_personality(struct io_ring_ctx *ctx)
103103
return id;
104104
}
105105

106+
/*
107+
* Returns number of restrictions parsed and added on success, or < 0 for
108+
* an error.
109+
*/
106110
static __cold int io_parse_restrictions(void __user *arg, unsigned int nr_args,
107111
struct io_restriction *restrictions)
108112
{
@@ -145,9 +149,7 @@ static __cold int io_parse_restrictions(void __user *arg, unsigned int nr_args,
145149
goto err;
146150
}
147151
}
148-
149-
ret = 0;
150-
152+
ret = nr_args;
151153
err:
152154
kfree(res);
153155
return ret;
@@ -168,11 +170,12 @@ static __cold int io_register_restrictions(struct io_ring_ctx *ctx,
168170

169171
ret = io_parse_restrictions(arg, nr_args, &ctx->restrictions);
170172
/* Reset all restrictions if an error happened */
171-
if (ret != 0)
173+
if (ret < 0) {
172174
memset(&ctx->restrictions, 0, sizeof(ctx->restrictions));
173-
else
174-
ctx->restrictions.registered = true;
175-
return ret;
175+
return ret;
176+
}
177+
ctx->restrictions.registered = true;
178+
return 0;
176179
}
177180

178181
static int io_register_enable_rings(struct io_ring_ctx *ctx)

0 commit comments

Comments
 (0)