]> git.hungrycats.org Git - linux/commitdiff
net: sparx5: free the matchall entry on destroy
authorDaniel Machon <daniel.machon@microchip.com>
Wed, 7 Oct 2026 15:03:15 +0000 (17:03 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 8 Oct 2026 17:55:23 +0000 (10:55 -0700)
sparx5_tc_matchall_replace() allocates a struct sparx5_mall_entry for
every offloaded matchall filter and adds it to sparx5->mall_entries.
sparx5_tc_matchall_destroy() removes the entry from the list, but never
frees it, so the entry of every deleted mirror and goto matchall filter
is leaked.

Free the entry after unlinking it.

The leak was discovered by an AI code review agent, and reproduced with
kmemleak on a lan969x EV board (EV23X71A) by repeatedly adding and
deleting matchall mirror and goto filters. With the fix, kmemleak no
longer reports the leak.

Cc: stable@vger.kernel.org
Fixes: 1ede4acf045c ("net: sparx5: add bookkeeping code for matchall rules")
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
Link: https://patch.msgid.link/20261007-sparx5-matchall-kfree-net-v1-1-c8918685b337@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c

index 702257979462d4fce61ede0aa14cf8079e68b234..146d7f28e8f3dde8cce09e528dd6447ebffe277c 100644 (file)
@@ -160,6 +160,7 @@ static int sparx5_tc_matchall_destroy(struct net_device *ndev,
        }
 
        list_del(&entry->list);
+       kfree(entry);
 
        return err;
 }