]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: sparx5: Fix use after free inside sparx5_del_mact_entry
authorHoratiu Vultur <horatiu.vultur@microchip.com>
Fri, 1 Mar 2024 08:06:08 +0000 (09:06 +0100)
committerSasha Levin <sashal@kernel.org>
Fri, 15 Mar 2024 14:48:16 +0000 (10:48 -0400)
commite83bebb718fd1f42549358730e1206164e0861d6
tree72e77b9433025328c688754267f3c97bb77c6334
parent0ece581d2a66e8e488c0d3b3e7b5760dbbfdbdd5
net: sparx5: Fix use after free inside sparx5_del_mact_entry

[ Upstream commit 89d72d4125e94aa3c2140fedd97ce07ba9e37674 ]

Based on the static analyzis of the code it looks like when an entry
from the MAC table was removed, the entry was still used after being
freed. More precise the vid of the mac_entry was used after calling
devm_kfree on the mac_entry.
The fix consists in first using the vid of the mac_entry to delete the
entry from the HW and after that to free it.

Fixes: b37a1bae742f ("net: sparx5: add mactable support")
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240301080608.3053468-1-horatiu.vultur@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c