Skip to content

Commit d3a8ca2

Browse files
nizhen-tij-intel
authored andcommitted
platform/x86/amd: hfi: Fix pcct_tbl leak in amd_hfi_metadata_parser()
Fix a permanent ACPI table memory leak when amd_hfi_metadata_parser() fails due to invalid PCCT table length or memory allocation errors. Fixes: d4e95ea ("platform/x86: hfi: Parse CPU core ranking data from shared memory") Cc: stable@vger.kernel.org Signed-off-by: Zhen Ni <zhen.ni@easystack.cn> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Link: https://lore.kernel.org/r/20250822083329.710857-1-zhen.ni@easystack.cn Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 748f897 commit d3a8ca2

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

  • drivers/platform/x86/amd/hfi

drivers/platform/x86/amd/hfi/hfi.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,19 +385,25 @@ static int amd_hfi_metadata_parser(struct platform_device *pdev,
385385
amd_hfi_data->pcct_entry = pcct_entry;
386386
pcct_ext = (struct acpi_pcct_ext_pcc_slave *)pcct_entry;
387387

388-
if (pcct_ext->length <= 0)
389-
return -EINVAL;
388+
if (pcct_ext->length <= 0) {
389+
ret = -EINVAL;
390+
goto out;
391+
}
390392

391393
amd_hfi_data->shmem = devm_kzalloc(amd_hfi_data->dev, pcct_ext->length, GFP_KERNEL);
392-
if (!amd_hfi_data->shmem)
393-
return -ENOMEM;
394+
if (!amd_hfi_data->shmem) {
395+
ret = -ENOMEM;
396+
goto out;
397+
}
394398

395399
pcc_chan->shmem_base_addr = pcct_ext->base_address;
396400
pcc_chan->shmem_size = pcct_ext->length;
397401

398402
/* parse the shared memory info from the PCCT table */
399403
ret = amd_hfi_fill_metadata(amd_hfi_data);
400404

405+
out:
406+
/* Don't leak any ACPI memory */
401407
acpi_put_table(pcct_tbl);
402408

403409
return ret;

0 commit comments

Comments
 (0)