RDMA/uverbs: Fix potential leak of resources->collection in flow_resources_alloc()

The two array allocations are done unconditionally and only checked
afterwards, so if the counters allocation fails while the collection
allocation succeeds, the error path frees counters and the containing
struct but never frees resources->collection, losing the only pointer
to it.

Fixes: de7498147d ("RDMA/uverbs: Refactor flow_resources_alloc() function")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Link: https://patch.msgid.link/20260826073146.2203-1-lirongqing@baidu.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
Li RongQing 2026-08-26 15:31:46 +08:00 committed by Leon Romanovsky
parent 23d7e03a52
commit 08d4d9802d

View File

@ -26,6 +26,7 @@ struct ib_uflow_resources *flow_resources_alloc(size_t num_specs)
return resources;
err:
kfree(resources->collection);
kfree(resources->counters);
kfree(resources);