net: fs_enet: fix platform info memory leak on remove
Subsystems (4)
PATCH 1/1 net: fs_enet: fix platform info memory leak on remove
fs_enet_probe() allocates the platform information structure with kzalloc_obj() and stores it in fep->fpi.
The probe failure paths release this allocation with kfree(). However, after a successful probe, fs_enet_remove() tears down the network device without freeing fep->fpi, leaving the platform information structure allocated after driver removal.
Free fep->fpi before releasing the network device.
This issue was found by manual code inspection.
--- drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +1 -0
@@ -1007,6 +1007,7 @@ static void fs_enet_remove(struct platform_device *ofdev) fep->ops->cleanup_data (ndev);dev_set_drvdata (fep->dev,NULL );phylink_destroy (fep->phylink); +kfree (fep->fpi);free_netdev (ndev); }
Signature · 1 line
2.43.0
Quoted 24 lines · Guangshuo Li
fs_enet_probe()allocates the platform information structure withkzalloc_obj()and stores it infep->fpi.The probe failure paths release this allocation with
kfree(). However, after a successful probe,fs_enet_remove()tears down the network device without freeingfep->fpi, leaving the platform information structure allocated after driver removal.Free
fep->fpibefore releasing the network device.This issue was found by manual code inspection.
Fixes 976de6a8c304 ("fs_enet: Be an of_platform device when CONFIG_PPC_CPM_NEW_BINDING is set.")Signed-off-by Guangshuo Li <[email protected]>--- drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +0
-0
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c static void fs_enet_remove(struct platform_device *ofdev) · line 1011
Quoted 5 lines
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +1
-0@@ -1007,6 +1007,7 @@ static void fs_enet_remove(struct platform_device *ofdev) fep->ops->cleanup_data (ndev);dev_set_drvdata (fep->dev,NULL );phylink_destroy (fep->phylink); +kfree (fep->fpi);free_netdev (ndev);
Quoted 8 lines · Guangshuo Li
fs_enet_probe()allocates the platform information structure withkzalloc_obj()and stores it infep->fpi.The probe failure paths release this allocation with
kfree(). However, after a successful probe,fs_enet_remove()tears down the network device without freeingfep->fpi, leaving the platform information structure allocated after driver removal.
Quoted 7 lines
Free
fep->fpibefore releasing the network device.This issue was found by manual code inspection.
Fixes 976de6a8c304 ("fs_enet: Be an of_platform device when CONFIG_PPC_CPM_NEW_BINDING is set.")Signed-off-by Guangshuo Li <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Wed, 16 Sep 2026 11:14:14 +0800 you wrote:
fs_enet_probe()allocates the platform information structure withkzalloc_obj()and stores it infep->fpi.The probe failure paths release this allocation with
kfree(). However, after a successful probe,fs_enet_remove()tears down the network device without freeingfep->fpi, leaving the platform information structure allocated after driver removal.[...]
Here is the summary with links:
- net: fs_enet: fix platform info memory leak on remove
https://git.kernel.org/netdev/net-next/c/4a6764900678
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html