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;