io_uring/rsrc: use io_cache_free() to free node allocated by io_rsrc_node_alloc()
PATCH 1/1 io_uring/rsrc: use io_cache_free() to free node allocated by io_rsrc_node_alloc()
From: Jackie Liu <[email protected]>
Replace kfree(node) with io_cache_free() in io_buffer_register_bvec() to match all other error paths that free nodes allocated via io_rsrc_node_alloc(). The node is allocated through io_cache_alloc() internally, so it should be returned to the cache via io_cache_free() for proper object reuse.
--- io_uring/rsrc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/rsrc.c +1 -1
@@ -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); ret = -ENOMEM ; goto unlock; }
Signature · 1 line
2.51.1
Jens Axboe
maintainerQuoted 19 lines · Jackie Liu
From: Jackie Liu <[email protected]>
Replace kfree(node) with
io_cache_free()inio_buffer_register_bvec()to match all other error paths that free nodes allocated viaio_rsrc_node_alloc(). The node is allocated throughio_cache_alloc()internally, so it should be returned to the cache viaio_cache_free()for proper object reuse.Fixes 27cb27b6d5ea ("io_uring: add support for kernel registered bvecs")Signed-off-by Jackie Liu <[email protected]>--- io_uring/rsrc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)io_uring/rsrc.c +0
-0
io_uring/rsrc.c int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct request *rq, · line 967
Quoted 8 lines
io_uring/rsrc.c +1
-1@@ -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); ret = -ENOMEM ; goto unlock; }
People have sent this before, but I usually just dismiss it with being an error path and it doesn't matter one bit if it stays in cache or just gets freed outright. But might make sense to apply it just for consistency's sake - and so I don't get it sent again!
Signature · 1 line
Jens Axboe
Quoted 8 lines · Jackie Liu
Replace kfree(node) with
io_cache_free()inio_buffer_register_bvec()to match all other error paths that free nodes allocated viaio_rsrc_node_alloc(). The node is allocated throughio_cache_alloc()internally, so it should be returned to the cache viaio_cache_free()for proper object reuse.[...]
Applied, thanks!
[1/1] io_uring/rsrc: use io_cache_free() to free node allocated by io_rsrc_node_alloc()
commit: 37912f1ea4ee2d8a4f36033fea4f44a044dd1cb9
Best regards,
Signature · 1 line
Jens Axboe