Messages in this thread |  | | Date | Tue, 5 May 2026 09:50:26 +0100 | | From | Sudeep Holla <> | | Subject | Re: [PATCH 4/5] perf: arm: pmu: fix reference leak on failed device registration |
| |
On Mon, May 04, 2026 at 01:08:46PM +0300, Vastargazing wrote: > When platform_device_register() fails in arm_acpi_register_pmu_device(), > the embedded struct device has already been initialized by > device_initialize() inside platform_device_register(). The error path > unregisters the GSI interrupt but returns without dropping the device > reference: > > arm_acpi_register_pmu_device() > -> platform_device_register(pdev) > -> device_initialize(&pdev->dev) /* kref = 1 */ > -> platform_device_add(pdev) /* fails */ > <- acpi_unregister_gsi() called, but kref still 1 > > Per platform_device_register() kernel-doc: > > NOTE: _Never_ directly free @pdev after calling this function, even if > it returned an error! Always use platform_device_put() to give up the > reference initialised in this function instead. > > Fix this by calling platform_device_put() in the error branch before > unregistering the GSI. > > Fixes: d24a0c7099b3 ("arm_pmu: acpi: spe: Add initial MADT/SPE probing") > Cc: stable@vger.kernel.org > Assisted-by: GitHub Copilot (Claude Sonnet 4.5) > Signed-off-by: Vastargazing <vebohr@gmail.com> > --- > drivers/perf/arm_pmu_acpi.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c > index e80f76d95e68..c2defbc32ad9 100644 > --- a/drivers/perf/arm_pmu_acpi.c > +++ b/drivers/perf/arm_pmu_acpi.c > @@ -119,8 +119,10 @@ arm_acpi_register_pmu_device(struct platform_device *pdev, u8 len, > > pdev->resource[0].start = irq; > ret = platform_device_register(pdev); > - if (ret) > + if (ret) { > + platform_device_put(pdev);
Both spe_dev and trbe_dev using this are statically allocated, what am I missing here ? What will platform_device_put() do ?
-- Regards, Sudeep
|  |