Re: [PATCH v5 7/9] ACPI: APEI: EINJ: Add debugfs files for EINJv2 support

From: Ira Weiny
Date: Fri Apr 04 2025 - 10:47:54 EST


Zaid Alali wrote:
> Create a debugfs blob file to be used for reading the user
> input for the component array. EINJv2 enables users to inject
> errors to multiple components/devices at the same time using
> component array.
>
> Signed-off-by: Zaid Alali <zaidal@xxxxxxxxxxxxxxxxxxxxxx>

[snip]

> @@ -890,6 +893,17 @@ static int __init einj_probe(struct platform_device *pdev)
> &error_param4);
> debugfs_create_x32("notrigger", S_IRUSR | S_IWUSR,
> einj_debug_dir, &notrigger);
> + if (available_error_type & ACPI65_EINJV2_SUPP) {
> + user_input = kzalloc(COMP_ARR_SIZE, GFP_KERNEL);
> + if (!user_input) {
> + rc = -ENOMEM;
> + goto err_alloc;
> + }
> + einjv2_component_arr.data = user_input;
> + einjv2_component_arr.size = COMP_ARR_SIZE;
> + debugfs_create_blob("einjv2_component_array", S_IRUSR | S_IWUSR,
> + einj_debug_dir, &einjv2_component_arr);
> + }
> }
>
> if (vendor_dev[0]) {
> @@ -909,6 +923,8 @@ static int __init einj_probe(struct platform_device *pdev)
>
> return 0;
>
> +err_alloc:
> + apei_exec_post_unmap_gars(&ctx);

The addition of an unmap call without a corresponding map call threw me.
I see that this is needed in this flow.

Why not attempt the kzalloc() right off in the function? This avoids the extra
goto and all the unwind path.

Like:

diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
index 04731a5b01fa..2993e0eb4f81 100644
--- a/drivers/acpi/apei/einj-core.c
+++ b/drivers/acpi/apei/einj-core.c
@@ -771,6 +771,10 @@ static int __init einj_probe(struct platform_device *pdev)
return -EINVAL;
}

+ user_input = kzalloc(COMP_ARR_SIZE, GFP_KERNEL);
+ if (!user_input)
+ return -ENOMEM;
+
rc = einj_check_table(einj_tab);
if (rc) {
pr_warn(FW_BUG "Invalid EINJ table.\n");


Or, perhaps better, just disable einjv2 if the alloc fails and not fail the probe?

Ira

[snip]