mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net: fs_enet: fix platform info memory leak on remove
@ 2026-09-16  3:14 Guangshuo Li
  2026-09-18  9:24 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Guangshuo Li @ 2026-09-16  3:14 UTC (permalink / raw)
  To: Pantelis Antoniou, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Jeff Garzik,
	Scott Wood, linuxppc-dev, netdev, linux-kernel
  Cc: Guangshuo Li, stable

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.

Fixes: 976de6a8c304 ("fs_enet: Be an of_platform device when CONFIG_PPC_CPM_NEW_BINDING is set.")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
index d3c772ed5fc9..071e3f3de78c 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -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);
 }
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: fs_enet: fix platform info memory leak on remove
  2026-09-16  3:14 [PATCH] net: fs_enet: fix platform info memory leak on remove Guangshuo Li
@ 2026-09-18  9:24 ` Simon Horman
  2026-09-18  9:30 ` Simon Horman
  2026-09-18 22:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2026-09-18  9:24 UTC (permalink / raw)
  To: Guangshuo Li
  Cc: Pantelis Antoniou, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Jeff Garzik,
	Scott Wood, linuxppc-dev, netdev, linux-kernel, stable

On Wed, Sep 16, 2026 at 11:14:14AM +0800, Guangshuo Li wrote:
> 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.
> 
> Fixes: 976de6a8c304 ("fs_enet: Be an of_platform device when CONFIG_PPC_CPM_NEW_BINDING is set.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
>  drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
> index d3c772ed5fc9..071e3f3de78c 100644
> --- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
> +++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
> @@ -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);

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: fs_enet: fix platform info memory leak on remove
  2026-09-16  3:14 [PATCH] net: fs_enet: fix platform info memory leak on remove Guangshuo Li
  2026-09-18  9:24 ` Simon Horman
@ 2026-09-18  9:30 ` Simon Horman
  2026-09-18 22:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2026-09-18  9:30 UTC (permalink / raw)
  To: Guangshuo Li
  Cc: Pantelis Antoniou, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Jeff Garzik,
	Scott Wood, linuxppc-dev, netdev, linux-kernel, stable

On Wed, Sep 16, 2026 at 11:14:14AM +0800, Guangshuo Li wrote:
> 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.
> 
> Fixes: 976de6a8c304 ("fs_enet: Be an of_platform device when CONFIG_PPC_CPM_NEW_BINDING is set.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: fs_enet: fix platform info memory leak on remove
  2026-09-16  3:14 [PATCH] net: fs_enet: fix platform info memory leak on remove Guangshuo Li
  2026-09-18  9:24 ` Simon Horman
  2026-09-18  9:30 ` Simon Horman
@ 2026-09-18 22:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-18 22:50 UTC (permalink / raw)
  To: Guangshuo Li
  Cc: pantelis.antoniou, andrew+netdev, davem, edumazet, kuba, pabeni,
	linux, jeff, scottwood, linuxppc-dev, netdev, linux-kernel,
	stable

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 16 Sep 2026 11:14:14 +0800 you wrote:
> 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.
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-18 22:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16  3:14 [PATCH] net: fs_enet: fix platform info memory leak on remove Guangshuo Li
2026-09-18  9:24 ` Simon Horman
2026-09-18  9:30 ` Simon Horman
2026-09-18 22:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®