[PATCH v2] riscv: cacheinfo: Fix node reference leak in populate_cache_leaves

Paul Walmsley pjw at kernel.org
Thu May 21 15:50:58 PDT 2026


On Sat, 9 May 2026, Zishun Yi wrote:

> Currently, the while loop drops the reference to prev in each iteration.
> If the loop terminates early due to a break, the final of_node_put(np)
> correctly drops the reference to the current node.
> 
> However, if the loop terminates naturally because np == NULL, calling
> of_node_put(np) is a no-op. This leaves the last valid node stored in
> prev without its reference dropped, resulting in a node reference leak.
> 
> Fix this by changing the final `of_node_put(np)` to `of_node_put(prev)`.
> 
> Fixes: 94f9bf118f1e ("RISC-V: Fix of_node_* refcount")
> Cc: stable at vger.kernel.org
> Assisted-by: Gemini:gemini-3.1-pro
> Signed-off-by: Zishun Yi <vulab at iscas.ac.cn>

Thanks, queued for v7.1-rc.


- Paul



More information about the linux-riscv mailing list