diff options
| author | Jens Axboe | 2026-02-05 08:38:20 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman | 2026-02-26 14:59:01 -0800 |
| commit | 445d35742d8636225d01e26f90fb49fa0327d8c1 (patch) | |
| tree | 6455daff97929e2531d3fa7138895bd9ffe11589 /io_uring | |
| parent | 6715560527e343a387e4a0d2e6c401748e89fa55 (diff) | |
io_uring/kbuf: fix memory leak if io_buffer_add_list fails
[ Upstream commit 442ae406603a94f1a263654494f425302ceb0445 ]
io_register_pbuf_ring() ignores the return value of io_buffer_add_list(),
which can fail if xa_store() returns an error (e.g., -ENOMEM). When this
happens, the function returns 0 (success) to the caller, but the
io_buffer_list structure is neither added to the xarray nor freed.
In practice this requires failure injection to hit, hence not a real
issue. But it should get fixed up none the less.
Fixes: c7fb19428d67 ("io_uring: add support for ring mapped supplied buffers")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'io_uring')
| -rw-r--r-- | io_uring/kbuf.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c index d974381d93ff..308ef71bcb28 100644 --- a/io_uring/kbuf.c +++ b/io_uring/kbuf.c @@ -669,8 +669,9 @@ int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg) bl->buf_ring = br; if (reg.flags & IOU_PBUF_RING_INC) bl->flags |= IOBL_INC; - io_buffer_add_list(ctx, bl, reg.bgid); - return 0; + ret = io_buffer_add_list(ctx, bl, reg.bgid); + if (!ret) + return 0; fail: io_free_region(ctx, &bl->region); kfree(bl); |
