[RFC 06/12] ACPI: TLBI: Parse domains from table

Jinqian Yang yangjinqian1 at huawei.com
Mon Oct 19 00:38:01 PDT 2026


Hi,

On 2026/10/1 19:06, Kristina Martšenko wrote:
> +static int __init parse_tlbi_table(void)
> +{
> +	struct acpi_table_header *table __free(acpi_put_table) =
> +		acpi_get_table_pointer(ACPI_SIG_TLBI, 0);
> +	u32 offset;
> +	int ret;
> +
> +	if (IS_ERR(table))
> +		return PTR_ERR(table);
> +
> +	tlbi = (struct acpi_table_tlbi *)table;
> +	if (tlbi->header.length < sizeof(*tlbi) ||
> +	    tlbi->domain_count > MAX_TLBI_DOMAINS)
> +		return -EINVAL;
> +	if (!tlbi->domain_count)
> +		return -ENOENT;
> +
> +	domain_count = tlbi->domain_count;
> +	domains = kcalloc(domain_count, sizeof(*domains), GFP_KERNEL);
> +	if (!domains)
> +		return -ENOMEM;
> +
> +	offset = tlbi->domains_offset;
> +
> +	for (int i = 0; i < domain_count; i++) {
> +		struct acpi_tlbi_domain *domain = tlbi_get_domain(offset);
> +
> +		if (!domain || domain->id > U16_MAX)
> +			return -EINVAL;
> +
> +		domains[i].id = domain->id;
> +		if (!zalloc_cpumask_var(&domains[i].cpus, GFP_KERNEL))
> +			return -ENOMEM;
> +
> +		ret = parse_tlbi_domain(domain, domains[i].cpus, 0);
> +		if (ret)
> +			return ret;
> +
> +		offset += domain->length;
> +	}
> +
> +	ret = validate_tlbi_domains();
> +	if (ret)
> +		return ret;
> +
> +	return 0;
> +}
> +
> +void __init acpi_tlbi_init(void)
> +{
> +	int ret;
> +
> +	if (!cpus_have_final_cap(ARM64_HAS_TLBID))
> +		return;
> +
> +	ret = parse_tlbi_table();
> +	if (ret) {
> +		if (ret != -ENOENT)
> +			pr_err("Failed to parse ACPI table\n");
> +		return;
> +	}
> +}

The error paths in parse_tlbi_table() return without freeing
"domains" or the cpumask already allocated.

Thanks,
Jinqian




More information about the linux-arm-kernel mailing list