Skip to content

Commit

Permalink
net: ethernet: mtk_eth_soc: fix NULL pointer on hw reset
Browse files Browse the repository at this point in the history
[ Upstream commit 604204f ]

When a hardware reset is triggered on devices not initializing WED the
calls to mtk_wed_fe_reset and mtk_wed_fe_reset_complete dereference a
pointer on uninitialized stack memory.
Break out of both functions in case a hw_list entry is 0.

Fixes: 08a764a ("net: ethernet: mtk_wed: add reset/reset_complete callbacks")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/5465c1609b464cc7407ae1530c40821dcdf9d3e6.1692634266.git.daniel@makrotopia.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
dangowrt authored and gregkh committed Aug 30, 2023
1 parent d56f830 commit 6500990
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/net/ethernet/mediatek/mtk_wed.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,13 @@ void mtk_wed_fe_reset(void)

for (i = 0; i < ARRAY_SIZE(hw_list); i++) {
struct mtk_wed_hw *hw = hw_list[i];
struct mtk_wed_device *dev = hw->wed_dev;
struct mtk_wed_device *dev;
int err;

if (!hw)
break;

dev = hw->wed_dev;
if (!dev || !dev->wlan.reset)
continue;

Expand All @@ -244,8 +248,12 @@ void mtk_wed_fe_reset_complete(void)

for (i = 0; i < ARRAY_SIZE(hw_list); i++) {
struct mtk_wed_hw *hw = hw_list[i];
struct mtk_wed_device *dev = hw->wed_dev;
struct mtk_wed_device *dev;

if (!hw)
break;

dev = hw->wed_dev;
if (!dev || !dev->wlan.reset_complete)
continue;

Expand Down

0 comments on commit 6500990

Please sign in to comment.