ghes_in_nmi_queue_one_entry() allocates a queue node using the error
status length read from the initial header. The subsequent full read
accepts a shorter error status, but ghes_proc_in_irq() recalculates the
size to free from that shorter record. This leaves part of the original
allocation in ghes_estatus_pool permanently allocated.
Store the allocation size in the queue node and use it whenever the node
is returned to the pool.
Fixes: d9f608dc1564 ("ACPI / APEI: Only use queued estatus entry during
in_nmi_queue_one_entry()")
Reported-by: [email protected]
Link:
https://sashiko.dev/#/message/20260708141940.75EA51F000E9%40smtp.kernel.org
Signed-off-by: Ahmed Tiba <[email protected]>
---
drivers/acpi/apei/ghes.c | 8 +++-----
include/acpi/ghes.h | 1 +
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 18dc77491277..03eee0b2500e 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -1348,7 +1348,6 @@ static void ghes_proc_in_irq(struct irq_work *irq_work)
struct ghes_estatus_node *estatus_node;
struct acpi_hest_generic *generic;
struct acpi_hest_generic_status *estatus;
- u32 len, node_len;
llnode = llist_del_all(&ghes_estatus_llist);
/*
@@ -1361,8 +1360,6 @@ static void ghes_proc_in_irq(struct irq_work *irq_work)
estatus_node = llist_entry(llnode, struct ghes_estatus_node,
llnode);
estatus = GHES_ESTATUS_FROM_NODE(estatus_node);
- len = cper_estatus_len(estatus);
- node_len = GHES_ESTATUS_NODE_LEN(len);
ghes_do_proc(estatus_node->ghes, estatus);
@@ -1372,7 +1369,7 @@ static void ghes_proc_in_irq(struct irq_work *irq_work)
ghes_estatus_cache_add(generic, estatus);
}
gen_pool_free(ghes_estatus_pool, (unsigned long)estatus_node,
- node_len);
+ estatus_node->node_len);
llnode = next;
}
@@ -1431,6 +1428,7 @@ static int ghes_in_nmi_queue_one_entry(struct ghes *ghes,
if (!estatus_node)
return -ENOMEM;
+ estatus_node->node_len = node_len;
estatus_node->ghes = ghes;
estatus_node->generic = ghes->generic;
estatus = GHES_ESTATUS_FROM_NODE(estatus_node);
@@ -1467,7 +1465,7 @@ static int ghes_in_nmi_queue_one_entry(struct ghes *ghes,
no_work:
gen_pool_free(ghes_estatus_pool, (unsigned long)estatus_node,
- node_len);
+ estatus_node->node_len);
return rc;
}
diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h
index 7acf209061ea..56274dbe3bff 100644
--- a/include/acpi/ghes.h
+++ b/include/acpi/ghes.h
@@ -37,6 +37,7 @@ struct ghes_estatus_node {
struct llist_node llnode;
struct acpi_hest_generic *generic;
struct ghes *ghes;
+ u32 node_len;
};
struct ghes_estatus_cache {
--
2.43.0