]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
of: fix reference count leak in of_alias_scan()
authorWeigang He <geoffreyhe2@gmail.com>
Sat, 17 Jan 2026 09:12:38 +0000 (09:12 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Jan 2026 09:27:38 +0000 (10:27 +0100)
commitf4c270975fe1ddcdbe4170d552e183bd688e2bfc
tree21aca12af53ed6ada64b8d4cb49dc0c0b9ee4afc
parent2757f7748ce2d0fa44112024907bafb37e104d6e
of: fix reference count leak in of_alias_scan()

commit 81122fba08fa3ccafab6ed272a5c6f2203923a7e upstream.

of_find_node_by_path() returns a device_node with its refcount
incremented. When kstrtoint() fails or dt_alloc() fails, the function
continues to the next iteration without calling of_node_put(), causing
a reference count leak.

Add of_node_put(np) before continue on both error paths to properly
release the device_node reference.

Fixes: 611cad720148 ("dt: add of_alias_scan and of_alias_get_id")
Cc: stable@vger.kernel.org
Signed-off-by: Weigang He <geoffreyhe2@gmail.com>
Link: https://patch.msgid.link/20260117091238.481243-1-geoffreyhe2@gmail.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/of/base.c