diff mbox series

[v2] ACPI: PCC: Release resources on address space setup failure path

Message ID 20220909153320.501347-1-rafaelmendsr@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series [v2] ACPI: PCC: Release resources on address space setup failure path | expand

Commit Message

Rafael Mendonca Sept. 9, 2022, 3:33 p.m. UTC
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")
Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
---
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(+)

Comments

Sudeep Holla Sept. 12, 2022, 8:20 a.m. UTC | #1
On Fri, Sep 09, 2022 at 12:33:19PM -0300, Rafael Mendonca wrote:
> 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!

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Rafael J. Wysocki Sept. 22, 2022, 7:05 p.m. UTC | #2
On Mon, Sep 12, 2022 at 10:20 AM Sudeep Holla <sudeep.holla@arm.com> wrote:
>
> On Fri, Sep 09, 2022 at 12:33:19PM -0300, Rafael Mendonca wrote:
> > 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!
>
> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
>

Applied as 6.1 material, thanks!
diff mbox series

Patch

diff --git a/drivers/acpi/acpi_pcc.c b/drivers/acpi/acpi_pcc.c
index a12b55d81209..84f1ac416b57 100644
--- a/drivers/acpi/acpi_pcc.c
+++ b/drivers/acpi/acpi_pcc.c
@@ -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;
 	}