OSDN Git Service

phy: cadence: Sierra: fix error handling bugs in probe()
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 15 Jan 2022 11:51:46 +0000 (14:51 +0300)
committerVinod Koul <vkoul@kernel.org>
Mon, 24 Jan 2022 04:05:31 +0000 (09:35 +0530)
commit29afbd769ca338fa14cbfbbc824f7dc457ed7f2e
tree7eadebf507bee603c9a8a47e0f9e2f7257983acb
parent6d1e6bcb31663ee83aaea1f171f3dbfe95dd4a69
phy: cadence: Sierra: fix error handling bugs in probe()

There are two bugs in the error handling:
1: If devm_of_phy_provider_register() fails then there was no cleanup.
2: The error handling called of_node_put(child) improperly leading to
   a use after free.  We are only holding the reference inside the loop
   so the last two gotos after the loop lead to a use after free bug.
   Fix this by cleaning up the partial allocations (or partial iterations)
   in the loop before doing the goto.

Fixes: a43f72ae136a ("phy: cadence: Sierra: Change MAX_LANES of Sierra to 16")
Fixes: 44d30d622821 ("phy: cadence: Add driver for Sierra PHY")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20220115115146.GC7552@kili
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/cadence/phy-cadence-sierra.c