]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nvmem: Drop OF node reference on nvmem_add_one_cell() failure
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Fri, 16 Jan 2026 17:08:43 +0000 (17:08 +0000)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:21:17 +0000 (07:21 -0500)
[ Upstream commit f397bc0781553d01b4cdba506c09334a31cb0ec5 ]

If nvmem_add_one_cell() failed, the ownership of "child" (or "info.np"),
thus its OF reference, is not passed further and function should clean
up by putting the reference it got via earlier of_node_get().  Note that
this is independent of references obtained via for_each_child_of_node()
loop.

Fixes: 50014d659617 ("nvmem: core: use nvmem_add_one_cell() in nvmem_add_cells_from_of()")
Cc: stable@vger.kernel.org
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
Link: https://patch.msgid.link/20260116170846.733558-2-srini@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvmem/core.c

index 387c88c55259541446901f0e539bbb0dd8c4c3de..ff68fd5ad3d6f2ef41a066273cc2058a1af1836d 100644 (file)
@@ -831,6 +831,7 @@ static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_nod
                kfree(info.name);
                if (ret) {
                        of_node_put(child);
+                       of_node_put(info.np);
                        return ret;
                }
        }