linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mailbox: pcc: Add missed acpi_put_table() to fix memory leak
@ 2025-07-30 12:45 Zhen Ni
  2025-08-01 14:35 ` Markus Elfring
  2025-08-04  7:41 ` [PATCH v2] " Zhen Ni
  0 siblings, 2 replies; 15+ messages in thread
From: Zhen Ni @ 2025-07-30 12:45 UTC (permalink / raw)
  To: sudeep.holla, jassisinghbrar; +Cc: linux-acpi, Zhen Ni

In pcc_mbox_probe(), the PCCT table acquired via acpi_get_table()
is only released in error paths but not in the success path. This
leads to a permanent ACPI memory leak when the driver successfully
initializes.

The label name 'err' is no longer accurate because it handles both:
1. Error cases
2. Success case

Signed-off-by: Zhen Ni <zhen.ni@easystack.cn>
---
 drivers/mailbox/pcc.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index f6714c233f5a..509b6a96c785 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c
@@ -763,19 +763,19 @@ static int pcc_mbox_probe(struct platform_device *pdev)
 					 GFP_KERNEL);
 	if (!pcc_mbox_channels) {
 		rc = -ENOMEM;
-		goto err;
+		goto out_put_pcct;
 	}
 
 	chan_info = devm_kcalloc(dev, count, sizeof(*chan_info), GFP_KERNEL);
 	if (!chan_info) {
 		rc = -ENOMEM;
-		goto err;
+		goto out_put_pcct;
 	}
 
 	pcc_mbox_ctrl = devm_kzalloc(dev, sizeof(*pcc_mbox_ctrl), GFP_KERNEL);
 	if (!pcc_mbox_ctrl) {
 		rc = -ENOMEM;
-		goto err;
+		goto out_put_pcct;
 	}
 
 	/* Point to the first PCC subspace entry */
@@ -796,17 +796,17 @@ static int pcc_mbox_probe(struct platform_device *pdev)
 		    !pcc_mbox_ctrl->txdone_irq) {
 			pr_err("Platform Interrupt flag must be set to 1");
 			rc = -EINVAL;
-			goto err;
+			goto out_put_pcct;
 		}
 
 		if (pcc_mbox_ctrl->txdone_irq) {
 			rc = pcc_parse_subspace_irq(pchan, pcct_entry);
 			if (rc < 0)
-				goto err;
+				goto out_put_pcct;
 		}
 		rc = pcc_parse_subspace_db_reg(pchan, pcct_entry);
 		if (rc < 0)
-			goto err;
+			goto out_put_pcct;
 
 		pcc_parse_subspace_shmem(pchan, pcct_entry);
 
@@ -827,9 +827,8 @@ static int pcc_mbox_probe(struct platform_device *pdev)
 	rc = mbox_controller_register(pcc_mbox_ctrl);
 	if (rc)
 		pr_err("Err registering PCC as Mailbox controller: %d\n", rc);
-	else
-		return 0;
-err:
+
+out_put_pcct:
 	acpi_put_table(pcct_tbl);
 	return rc;
 }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2025-08-08  4:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-30 12:45 [PATCH] mailbox: pcc: Add missed acpi_put_table() to fix memory leak Zhen Ni
2025-08-01 14:35 ` Markus Elfring
2025-08-04  7:41 ` [PATCH v2] " Zhen Ni
2025-08-04  8:42   ` Markus Elfring
2025-08-04 12:14   ` [PATCH v3] " Zhen Ni
2025-08-04 14:06     ` Markus Elfring
2025-08-05  3:48     ` [PATCH v4] " Zhen Ni
2025-08-05  6:28       ` Markus Elfring
2025-08-05  7:26         ` Greg KH
2025-08-06 15:31       ` Sudeep Holla
2025-08-07  3:28       ` [PATCH v5] " Zhen Ni
2025-08-07 14:13         ` Sudeep Holla
2025-08-07 13:40       ` [PATCH v4] " Aithal, Srikanth
2025-08-07 14:08         ` Sudeep Holla
2025-08-08  4:33         ` Jassi Brar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).