linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhen Ni <zhen.ni@easystack.cn>
To: Markus.Elfring@web.de, sudeep.holla@arm.com, jassisinghbrar@gmail.com
Cc: linux-acpi@vger.kernel.org, Zhen Ni <zhen.ni@easystack.cn>,
	stable@vger.kernel.org
Subject: [PATCH v3] mailbox: pcc: Add missed acpi_put_table() to fix memory leak
Date: Mon,  4 Aug 2025 20:14:53 +0800	[thread overview]
Message-ID: <20250804121453.75525-1-zhen.ni@easystack.cn> (raw)
In-Reply-To: <20250804074115.44573-1-zhen.ni@easystack.cn>

In pcc_mbox_probe(), the PCCT table acquired via acpi_get_table() is
only released in error paths but not in the success path. Fix a
permanent ACPI memory leak when the driver successfully initializes. Add
the goto label 'err_nomem'.

Fixes: ce028702ddbc ("mailbox: pcc: Move bulk of PCCT parsing into pcc_mbox_probe")
Cc: stable@vger.kernel.org
Signed-off-by: Zhen Ni <zhen.ni@easystack.cn>
---
Changes in v2:
- Add tags of 'Fixes' and 'Cc'
- Change goto target from out_put_pcct to e_nomem
---
Changes in v3:
- Add goto label err_nomem, keep the err label.
- Update commit msg
---
 drivers/mailbox/pcc.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index f6714c233f5a..b5ce3a5d2e7a 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c
@@ -761,22 +761,16 @@ static int pcc_mbox_probe(struct platform_device *pdev)
 
 	pcc_mbox_channels = devm_kcalloc(dev, count, sizeof(*pcc_mbox_channels),
 					 GFP_KERNEL);
-	if (!pcc_mbox_channels) {
-		rc = -ENOMEM;
-		goto err;
-	}
+	if (!pcc_mbox_channels)
+		goto err_nomem;
 
 	chan_info = devm_kcalloc(dev, count, sizeof(*chan_info), GFP_KERNEL);
-	if (!chan_info) {
-		rc = -ENOMEM;
-		goto err;
-	}
+	if (!chan_info)
+		goto err_nomem;
 
 	pcc_mbox_ctrl = devm_kzalloc(dev, sizeof(*pcc_mbox_ctrl), GFP_KERNEL);
-	if (!pcc_mbox_ctrl) {
-		rc = -ENOMEM;
-		goto err;
-	}
+	if (!pcc_mbox_ctrl)
+		goto err_nomem;
 
 	/* Point to the first PCC subspace entry */
 	pcct_entry = (struct acpi_subtable_header *) (
@@ -827,8 +821,11 @@ 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;
+	goto err;
+
+err_nomem:
+	rc = -ENOMEM;
+	goto err;
 err:
 	acpi_put_table(pcct_tbl);
 	return rc;
-- 
2.20.1


  parent reply	other threads:[~2025-08-04 15:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Zhen Ni [this message]
2025-08-04 14:06     ` [PATCH v3] " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250804121453.75525-1-zhen.ni@easystack.cn \
    --to=zhen.ni@easystack.cn \
    --cc=Markus.Elfring@web.de \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=sudeep.holla@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).