Skip to content

Commit 89d72d4

Browse files
HoratiuVulturkuba-moo
authored andcommitted
net: sparx5: Fix use after free inside sparx5_del_mact_entry
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: b37a1ba ("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>
1 parent 948abb5 commit 89d72d4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,10 @@ int sparx5_del_mact_entry(struct sparx5 *sparx5,
347347
list) {
348348
if ((vid == 0 || mact_entry->vid == vid) &&
349349
ether_addr_equal(addr, mact_entry->mac)) {
350+
sparx5_mact_forget(sparx5, addr, mact_entry->vid);
351+
350352
list_del(&mact_entry->list);
351353
devm_kfree(sparx5->dev, mact_entry);
352-
353-
sparx5_mact_forget(sparx5, addr, mact_entry->vid);
354354
}
355355
}
356356
mutex_unlock(&sparx5->mact_lock);

0 commit comments

Comments
 (0)