Skip to contentSkip to conversation

ACPI: PCC: Release resources on address space setup failure path

PATCH Applied Rafael Mendonca 3 participants 3 messages Sep 9, 2022 – Sep 22, 2022 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ACPI: PCC: Release resources on address space setup failure path

The allocated memory for the pcc_data struct doesn't get freed under an error path in pcc_mbox_request_channel() or acpi_os_ioremap(). Also, the PCC mailbox channel doesn't get freed under an error path in acpi_os_ioremap().

Fixes 77e2a04745ff8 ("ACPI: PCC: Implement OperationRegion handler for the PCC Type 3 subtype")

---
v1->v2
- Add PCC mailbox channel release to the unwind path
- Update commit msg to reflect the addition of the mailbox free

---
 drivers/acpi/acpi_pcc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/acpi/acpi_pcc.c +3 -0
index a12b55d81209..84f1ac416b57 100644
@@ -63,6 +63,7 @@ acpi_pcc_address_space_setup(acpi_handle region_handle, u32 function,
 	if (IS_ERR(data->pcc_chan)) {
 		pr_err("Failed to find PCC channel for subspace %d\n",
 		       ctx->subspace_id);
+		kfree(data);
 		return AE_NOT_FOUND;
 	}
 
@@ -72,6 +73,8 @@ acpi_pcc_address_space_setup(acpi_handle region_handle, u32 function,
 	if (!data->pcc_comm_addr) {
 		pr_err("Failed to ioremap PCC comm region mem for %d\n",
 		       ctx->subspace_id);
+		pcc_mbox_free_channel(data->pcc_chan);
+		kfree(data);
 		return AE_NO_MEMORY;
 	}
 
Signature · 1 line
2.34.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · Rafael Mendonca

The allocated memory for the pcc_data struct doesn't get freed under an error path in pcc_mbox_request_channel() or acpi_os_ioremap(). Also, the PCC mailbox channel doesn't get freed under an error path in acpi_os_ioremap().

Thanks!

Signature · 2 lines
Regards,
Sudeep
maintainer Applied
#2 lore raw
Quoted 8 lines · Sudeep Holla
Quoted 5 lines · Rafael Mendonca

The allocated memory for the pcc_data struct doesn't get freed under an error path in pcc_mbox_request_channel() or acpi_os_ioremap(). Also, the PCC mailbox channel doesn't get freed under an error path in acpi_os_ioremap().

Quoted 4 lines

Thanks!

Applied as 6.1 material, thanks!