Skip to content

Commit 7b0604d

Browse files
tobluxaxboe
authored andcommitted
io_uring: Replace kzalloc() + copy_from_user() with memdup_user()
Replace kzalloc() followed by copy_from_user() with memdup_user() to improve and simplify io_probe(). No functional changes intended. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 473efbc commit 7b0604d

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

io_uring/register.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,9 @@ static __cold int io_probe(struct io_ring_ctx *ctx, void __user *arg,
4747
nr_args = IORING_OP_LAST;
4848

4949
size = struct_size(p, ops, nr_args);
50-
p = kzalloc(size, GFP_KERNEL);
51-
if (!p)
52-
return -ENOMEM;
53-
54-
ret = -EFAULT;
55-
if (copy_from_user(p, arg, size))
56-
goto out;
50+
p = memdup_user(arg, size);
51+
if (IS_ERR(p))
52+
return PTR_ERR(p);
5753
ret = -EINVAL;
5854
if (memchr_inv(p, 0, size))
5955
goto out;

0 commit comments

Comments
 (0)