public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Pavel Begunkov <asml.silence@gmail.com>, KobaK <kobak@nvidia.com>
Cc: Keith Busch <kbusch@kernel.org>, Ming Lei <ming.lei@redhat.com>,
	io-uring@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] io_uring/rsrc: use io_cache_free for node in io_buffer_register_bvec error path
Date: Wed, 8 Apr 2026 06:49:23 -0600	[thread overview]
Message-ID: <7850ad0e-5124-4165-be96-3c5b4af0b723@kernel.dk> (raw)
In-Reply-To: <b3ed9023-3211-4f1f-a264-e71df5ba898b@gmail.com>

On 4/8/26 2:35 AM, Pavel Begunkov wrote:
> On 4/8/26 07:54, KobaK wrote:
>> From: Koba Ko <kobak@nvidia.com>
>>
>> io_buffer_register_bvec() allocates the rsrc node via
>> io_rsrc_node_alloc() which pulls from ctx->node_cache. On imu allocation
>> failure, the node is freed with raw kfree() instead of
>> io_cache_free(&ctx->node_cache, node), bypassing the cache return path
>> and wasting a reuse opportunity. Every other error path in this file
>> correctly uses io_cache_free for nodes.
>>
>> Fixes: 27cb27b6d5ea4 ("io_uring: add support for kernel registered bvecs")
>> Signed-off-by: Koba Ko <kobak@nvidia.com>
>> ---
>>   io_uring/rsrc.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
>> index 1b96ab5e98c99..6f46cf9cd13d7 100644
>> --- a/io_uring/rsrc.c
>> +++ b/io_uring/rsrc.c
>> @@ -961,7 +961,7 @@ int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct request *rq,
>>        */
>>       imu = io_alloc_imu(ctx, blk_rq_nr_phys_segments(rq));
>>       if (!imu) {
>> -        kfree(node);
>> +        io_cache_free(&ctx->node_cache, node);
> 
> Looks like it was already patched a week ago

Indeed, and main motivation was to eliminate reports like this, where
(clearly) an LLM spotted the "problem" even if there is none. Guess that
was a good move, just need it to land so that we don't need to waste
time on this again.

Nobody cares about "wasting a reuse opportunity" in an error path, any
human would recognize that.

-- 
Jens Axboe

  reply	other threads:[~2026-04-08 12:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-08  6:54 [PATCH 0/3] io_uring: fix resource leak issues KobaK
2026-04-08  6:54 ` [PATCH 1/3] io_uring: fix pinned pages and pages array leak in io_region_pin_pages() KobaK
2026-04-08  8:34   ` Pavel Begunkov
2026-04-08  6:54 ` [PATCH 2/3] io_uring/rsrc: use io_cache_free for node in io_buffer_register_bvec error path KobaK
2026-04-08  8:35   ` Pavel Begunkov
2026-04-08 12:49     ` Jens Axboe [this message]
2026-04-08  6:54 ` [PATCH 3/3] io_uring/zcrx: fix resource leak and double-free hazard in io_import_umem KobaK
2026-04-08  9:06   ` Pavel Begunkov
2026-04-08 12:51 ` [PATCH 0/3] io_uring: fix resource leak issues Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7850ad0e-5124-4165-be96-3c5b4af0b723@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --cc=io-uring@vger.kernel.org \
    --cc=kbusch@kernel.org \
    --cc=kobak@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox