Skip to content

Commit

Permalink
io_uring: fix xa_alloc_cycle() error return value check
Browse files Browse the repository at this point in the history
[ Upstream commit a30f895 ]

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: stable@vger.kernel.org
Fixes: 61cf937 ("io_uring: Convert personality_idr to XArray")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
axboe authored and Sasha Levin committed Aug 26, 2021
1 parent 515b612 commit a57b2a7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions fs/io_uring.c
Expand Up @@ -9835,10 +9835,11 @@ static int io_register_personality(struct io_ring_ctx *ctx)

ret = xa_alloc_cyclic(&ctx->personalities, &id, (void *)creds,
XA_LIMIT(0, USHRT_MAX), &ctx->pers_next, GFP_KERNEL);
if (!ret)
return id;
put_cred(creds);
return ret;
if (ret < 0) {
put_cred(creds);
return ret;
}
return id;
}

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

0 comments on commit a57b2a7

Please sign in to comment.