]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
of: Fix error path in of_parse_phandle_with_args_map()
authorHerve Codina <herve.codina@bootlin.com>
Mon, 2 Dec 2024 16:58:19 +0000 (17:58 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Dec 2024 12:53:01 +0000 (13:53 +0100)
commit76db8a75f04750167ee52ffc171b877c7d629d75
tree9a14464216da7d6cf531ce3e0830df7d3cbb0d08
parent4fa2c639fc09cb2d9a3595e9660995771b5b5436
of: Fix error path in of_parse_phandle_with_args_map()

commit d7dfa7fde63dde4d2ec0083133efe2c6686c03ff upstream.

The current code uses some 'goto put;' to cancel the parsing operation
and can lead to a return code value of 0 even on error cases.

Indeed, some goto calls are done from a loop without setting the ret
value explicitly before the goto call and so the ret value can be set to
0 due to operation done in previous loop iteration. For instance match
can be set to 0 in the previous loop iteration (leading to a new
iteration) but ret can also be set to 0 it the of_property_read_u32()
call succeed. In that case if no match are found or if an error is
detected the new iteration, the return value can be wrongly 0.

Avoid those cases setting the ret value explicitly before the goto
calls.

Fixes: bd6f2fd5a1d5 ("of: Support parsing phandle argument lists through a nexus node")
Cc: stable@vger.kernel.org
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Link: https://lore.kernel.org/r/20241202165819.158681-1-herve.codina@bootlin.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/of/base.c