[PATCH v8 10/22] ACPI: APEI: GHES: keep task work valid through error reporting

From: Ahmed Tiba

Date: Thu Dec 03 2026 - 08:41:41 EST


memory_failure_cb() returns its task-work allocation to
ghes_estatus_pool before handling the result from memory_failure(). When
memory_failure() returns an unhandled error, the diagnostic path reads
twcb->pfn after the allocation has been returned to the pool and may have
been reused.

Keep the task-work allocation valid until result handling and diagnostic
reporting have completed. Return it to the pool through a common cleanup
path after its final use.

Fixes: c1f1fda14137 ("ACPI: APEI: handle synchronous exceptions in task work")
Reported-by: sashiko-bot@xxxxxxxxxx
Link: https://sashiko.dev/#/message/20260708144441.6E1181F000E9%40smtp.kernel.org
Signed-off-by: Ahmed Tiba <ahmed.tiba@xxxxxxx>
---
drivers/acpi/apei/ghes.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index b48b1f56a429..94f539f5d676 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -521,14 +521,15 @@ static void memory_failure_cb(struct callback_head *twork)
int ret;

ret = memory_failure(twcb->pfn, twcb->flags);
- gen_pool_free(ghes_estatus_pool, (unsigned long)twcb, sizeof(*twcb));
-
if (!ret || ret == -EHWPOISON || ret == -EOPNOTSUPP)
- return;
+ goto out;

pr_err("%#llx: Sending SIGBUS to %s:%d due to hardware memory corruption\n",
twcb->pfn, current->comm, task_pid_nr(current));
force_sig(SIGBUS);
+
+out:
+ gen_pool_free(ghes_estatus_pool, (unsigned long)twcb, sizeof(*twcb));
}

static bool ghes_do_memory_failure(u64 physical_addr, int flags)

--
2.43.0