Re: [PATCH v3] soc: dove: fix OF node leaks in dove_init_pmu()
From: Andrew Lunn
Date: Fri Dec 04 2026 - 14:16:50 EST
On Tue, Dec 01, 2026 at 09:59:49AM +0800, zhaofeng2 wrote:
> From: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>
>
> dove_init_pmu() takes two OF node references: np_pmu via
> of_find_compatible_node() and domains_node via of_get_child_by_name().
> On success np_pmu is transferred to the long-lived pmu_data
> (pmu->of_node), but several paths leak references:
>
> - missing domains node: np_pmu is leaked;
> - pmu allocation failure: np_pmu and domains_node are leaked;
> - of_iomap() failure: both are leaked (pmu is freed, dropping the
> only holder of the np_pmu reference);
> - success: domains_node is never released after the child-node
> loop.
>
> Drop the references on all these paths. The np_pmu reference on the
> success path stays with pmu->of_node, which lives for the lifetime
> of the system.
>
> Signed-off-by: Zhao Feng <zhaofeng2@xxxxxxxxxxxxxxxxxxxx>
Reviewed-by: Andrew Lunn <andrew@xxxxxxx>
Andrew