Re: [PATCH] riscv: Prevent a bad reference count on CPU nodes

From: Sudeep Holla
Date: Fri Sep 13 2024 - 05:07:40 EST


On Fri, Sep 13, 2024 at 10:00:52AM +0200, Miquel Sabaté Solà wrote:
> When populating cache leaves we previously fetched the CPU device node
> at the very beginning. But when ACPI is enabled we go through a
> specific branch which returns early and does not call 'of_node_put' for
> the node that was acquired.
>
> Since we are not using a CPU device node for the ACPI code anyways, we
> can simply move the initialization of it just passed the ACPI block, and
> we are guaranteed to have an 'of_node_put' call for the acquired node.
> This prevents a bad reference count of the CPU device node.
>
> Moreover, the previous function did not check for errors when acquiring
> the device node, so a return -ENOENT has been added for that case.
>

LGTM,

Reviewed-by: Sudeep Holla <sudeep.holla@xxxxxxx>

> Signed-off-by: Miquel Sabaté Solà <mikisabate@xxxxxxxxx>
> ---
> I was wondering if this should also be sent to stable, but I have not seen
> a report on it, and this is not responsible for an oops or anything like that.
> So in the end I decided not to, but maybe you consider otherwise.
>

Right, it is not a fix per say and hence not a stable material as ACPI
is not accessing the node pointer.

--
Regards,
Sudeep