mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net: fman: Unregister ethernet device on removal
@ 2022-11-03 18:28 Sean Anderson
  2022-11-03 19:07 ` Sean Anderson
  2022-11-05  3:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Sean Anderson @ 2022-11-03 18:28 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: Madalin Bucur, linux-kernel, Sean Anderson

When the mac device gets removed, it leaves behind the ethernet device.
This will result in a segfault next time the ethernet device accesses
mac_dev. Remove the ethernet device when we get removed to prevent
this. This is not completely reversible, since some resources aren't
cleaned up properly, but that can be addressed later.

Fixes: 3933961682a3 ("fsl/fman: Add FMan MAC driver")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---
So... why *do* we have a separate device for the ethernet interface?
Can't the mac device just register the netdev itself?

 drivers/net/ethernet/freescale/fman/mac.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
index 65df308bad97..13e67f2864be 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -487,12 +487,21 @@ static int mac_probe(struct platform_device *_of_dev)
 	return err;
 }
 
+static int mac_remove(struct platform_device *pdev)
+{
+	struct mac_device *mac_dev = platform_get_drvdata(pdev);
+
+	platform_device_unregister(mac_dev->priv->eth_dev);
+	return 0;
+}
+
 static struct platform_driver mac_driver = {
 	.driver = {
 		.name		= KBUILD_MODNAME,
 		.of_match_table	= mac_match,
 	},
 	.probe		= mac_probe,
+	.remove		= mac_remove,
 };
 
 builtin_platform_driver(mac_driver);
-- 
2.35.1.1320.gc452695387.dirty


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

* Re: [PATCH] net: fman: Unregister ethernet device on removal
  2022-11-03 18:28 [PATCH] net: fman: Unregister ethernet device on removal Sean Anderson
@ 2022-11-03 19:07 ` Sean Anderson
  2022-11-05  3:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Sean Anderson @ 2022-11-03 19:07 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
  Cc: Madalin Bucur, linux-kernel

On 11/3/22 14:28, Sean Anderson wrote:
> When the mac device gets removed, it leaves behind the ethernet device.
> This will result in a segfault next time the ethernet device accesses
> mac_dev. Remove the ethernet device when we get removed to prevent
> this. This is not completely reversible, since some resources aren't
> cleaned up properly, but that can be addressed later.
> 
> Fixes: 3933961682a3 ("fsl/fman: Add FMan MAC driver")
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
> So... why *do* we have a separate device for the ethernet interface?
> Can't the mac device just register the netdev itself?
> 
>  drivers/net/ethernet/freescale/fman/mac.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
> index 65df308bad97..13e67f2864be 100644
> --- a/drivers/net/ethernet/freescale/fman/mac.c
> +++ b/drivers/net/ethernet/freescale/fman/mac.c
> @@ -487,12 +487,21 @@ static int mac_probe(struct platform_device *_of_dev)
>  	return err;
>  }
>  
> +static int mac_remove(struct platform_device *pdev)
> +{
> +	struct mac_device *mac_dev = platform_get_drvdata(pdev);
> +
> +	platform_device_unregister(mac_dev->priv->eth_dev);
> +	return 0;
> +}
> +
>  static struct platform_driver mac_driver = {
>  	.driver = {
>  		.name		= KBUILD_MODNAME,
>  		.of_match_table	= mac_match,
>  	},
>  	.probe		= mac_probe,
> +	.remove		= mac_remove,
>  };
>  
>  builtin_platform_driver(mac_driver);

err, this should be [PATCH net]. Sorry, will fix if necessary for a v2.

--Sena

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

* Re: [PATCH] net: fman: Unregister ethernet device on removal
  2022-11-03 18:28 [PATCH] net: fman: Unregister ethernet device on removal Sean Anderson
  2022-11-03 19:07 ` Sean Anderson
@ 2022-11-05  3:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-11-05  3:00 UTC (permalink / raw)
  To: Sean Anderson
  Cc: davem, edumazet, kuba, pabeni, netdev, madalin.bucur, linux-kernel

Hello:

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

On Thu,  3 Nov 2022 14:28:30 -0400 you wrote:
> When the mac device gets removed, it leaves behind the ethernet device.
> This will result in a segfault next time the ethernet device accesses
> mac_dev. Remove the ethernet device when we get removed to prevent
> this. This is not completely reversible, since some resources aren't
> cleaned up properly, but that can be addressed later.
> 
> Fixes: 3933961682a3 ("fsl/fman: Add FMan MAC driver")
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> 
> [...]

Here is the summary with links:
  - net: fman: Unregister ethernet device on removal
    https://git.kernel.org/netdev/net/c/b7cbc6740bd6

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] 3+ messages in thread

end of thread, other threads:[~2022-11-05  3:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 18:28 [PATCH] net: fman: Unregister ethernet device on removal Sean Anderson
2022-11-03 19:07 ` Sean Anderson
2022-11-05  3:00 ` 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®