Skip to content

Commit a30f895

Browse files
committed
io_uring: fix xa_alloc_cycle() error return value check
We currently check for ret != 0 to indicate error, but '1' is a valid return and just indicates that the allocation succeeded with a wrap. Correct the check to be for < 0, like it was before the xarray conversion. Cc: [email protected] Fixes: 61cf937 ("io_uring: Convert personality_idr to XArray") Signed-off-by: Jens Axboe <[email protected]>
1 parent 9cb0073 commit a30f895

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fs/io_uring.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9843,10 +9843,11 @@ static int io_register_personality(struct io_ring_ctx *ctx)
98439843

98449844
ret = xa_alloc_cyclic(&ctx->personalities, &id, (void *)creds,
98459845
XA_LIMIT(0, USHRT_MAX), &ctx->pers_next, GFP_KERNEL);
9846-
if (!ret)
9847-
return id;
9848-
put_cred(creds);
9849-
return ret;
9846+
if (ret < 0) {
9847+
put_cred(creds);
9848+
return ret;
9849+
}
9850+
return id;
98509851
}
98519852

98529853
static int io_register_restrictions(struct io_ring_ctx *ctx, void __user *arg,

0 commit comments

Comments
 (0)