ghes_estatus_cache_add() allocates a new cache entry before looking for a slot. If every populated slot has a zero average period, the selection loop can leave slot at -1. The unpublished entry and its allocation counter are then leaked.
Return the entry to ghes_estatus_pool and balance the allocation counter when no slot is selected. Reported-by: [email protected] Link: https://sashiko.dev/#/message/20260617141000.8392A1F000E9%40smtp.kernel.org Signed-off-by: Ahmed Tiba <[email protected]> --- drivers/acpi/apei/ghes.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index d4ddf3c79216..b38806d205ab 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -1233,6 +1233,10 @@ ghes_estatus_cache_add(struct acpi_hest_generic *generic, if (victim) call_rcu(&unrcu_pointer(victim)->rcu, ghes_estatus_cache_rcu_free); + } else { + gen_pool_free(ghes_estatus_pool, (unsigned long)new_cache, + GHES_ESTATUS_CACHE_LEN(new_cache->estatus_len)); + atomic_dec(&ghes_estatus_cache_alloced); } } -- 2.43.0
